aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-11 05:46:15 +0800
committerkumavis <aaron@kumavis.me>2017-01-11 05:46:15 +0800
commit8e3661555d789037542d09d4135f5750d5b29222 (patch)
treea32c2a3cba2014b27ac1a621f6b9c6093491bcc7
parent464b7d581424c04340281878a2a0f20e73bf8188 (diff)
downloadtangerine-wallet-browser-8e3661555d789037542d09d4135f5750d5b29222.tar
tangerine-wallet-browser-8e3661555d789037542d09d4135f5750d5b29222.tar.gz
tangerine-wallet-browser-8e3661555d789037542d09d4135f5750d5b29222.tar.bz2
tangerine-wallet-browser-8e3661555d789037542d09d4135f5750d5b29222.tar.lz
tangerine-wallet-browser-8e3661555d789037542d09d4135f5750d5b29222.tar.xz
tangerine-wallet-browser-8e3661555d789037542d09d4135f5750d5b29222.tar.zst
tangerine-wallet-browser-8e3661555d789037542d09d4135f5750d5b29222.zip
gulp - add disc bundle analysis task
-rw-r--r--.gitignore1
-rw-r--r--gulpfile.js56
-rw-r--r--package.json3
3 files changed, 55 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index af6449834..c61847aab 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ test/bower_components
package
.DS_Store
builds/
+disc/
notes.txt
app/.DS_Store
development/bundle.js
diff --git a/gulpfile.js b/gulpfile.js
index 9f55e99a8..f9eb663b6 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1,5 +1,6 @@
var watchify = require('watchify')
var browserify = require('browserify')
+var disc = require('disc')
var gulp = require('gulp')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
@@ -21,6 +22,7 @@ var replace = require('gulp-replace')
var disclaimer = fs.readFileSync(path.join(__dirname, 'USER_AGREEMENT.md')).toString()
var crypto = require('crypto')
var hash = crypto.createHash('sha256')
+var mkdirp = require('mkdirp')
hash.update(disclaimer)
var tosHash = hash.digest('hex')
@@ -172,18 +174,27 @@ const jsFiles = [
'popup',
]
+// bundle tasks
+
var jsDevStrings = jsFiles.map(jsFile => `dev:js:${jsFile}`)
var jsBuildStrings = jsFiles.map(jsFile => `build:js:${jsFile}`)
jsFiles.forEach((jsFile) => {
- gulp.task(`dev:js:${jsFile}`, bundleTask({ watch: true, filename: `${jsFile}.js` }))
- gulp.task(`build:js:${jsFile}`, bundleTask({ watch: false, filename: `${jsFile}.js` }))
+ gulp.task(`dev:js:${jsFile}`, bundleTask({ watch: true, label: jsFile, filename: `${jsFile}.js` }))
+ gulp.task(`build:js:${jsFile}`, bundleTask({ watch: false, label: jsFile, filename: `${jsFile}.js` }))
})
gulp.task('dev:js', gulp.parallel(...jsDevStrings))
-
gulp.task('build:js', gulp.parallel(...jsBuildStrings))
+// disc bundle analyzer tasks
+
+jsFiles.forEach((jsFile) => {
+ gulp.task(`disc:${jsFile}`, bundleTask({ label: jsFile, filename: `${jsFile}.js` }))
+})
+
+gulp.task('disc', gulp.parallel(jsFiles.map(jsFile => `disc:${jsFile}`)))
+
// clean dist
@@ -235,7 +246,7 @@ function zipTask(target) {
}
}
-function bundleTask(opts) {
+function generateBundler(opts) {
var browserifyOpts = assign({}, watchify.args, {
entries: ['./app/scripts/'+opts.filename],
plugin: 'browserify-derequire',
@@ -243,7 +254,42 @@ function bundleTask(opts) {
fullPaths: debug,
})
- var bundler = browserify(browserifyOpts)
+ return browserify(browserifyOpts)
+}
+
+function discTask(opts) {
+ let bundler = generateBundler(opts)
+
+ if (opts.watch) {
+ bundler = watchify(bundler)
+ bundler.on('update', performBundle) // on any dep update, runs the bundler
+ }
+
+ bundler.on('log', gutil.log) // output build logs to terminal
+
+ return performBundle
+
+ function performBundle(){
+ // start "disc" build
+ let discDir = path.join(__dirname, 'disc')
+ mkdirp.sync(discDir)
+ let discPath = path.join(discDir, `${opts.label}.html`)
+
+ return (
+ bundler.bundle()
+ .pipe(disc())
+ .pipe(fs.createWriteStream(discPath))
+ // .once('close', function() {
+ // console.log(`disc: ${opts.label} build completed.`)
+ // })
+ )
+ }
+}
+
+
+function bundleTask(opts) {
+ let bundler = generateBundler(opts)
+
if (opts.watch) {
bundler = watchify(bundler)
bundler.on('update', performBundle) // on any dep update, runs the bundler
diff --git a/package.json b/package.json
index e49ca0c72..ad9cf8f9b 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,7 @@
"lint": "gulp lint",
"buildCiUnits": "node test/integration/index.js",
"dev": "gulp dev --debug",
+ "disc": "gulp disc --debug",
"dist": "gulp dist --disableLiveReload",
"test": "npm run fastTest && npm run ci && npm run lint",
"fastTest": "METAMASK_ENV=test mocha --require test/helper.js --compilers js:babel-register --recursive \"test/unit/**/*.js\"",
@@ -42,6 +43,7 @@
"copy-to-clipboard": "^2.0.0",
"debounce": "^1.0.0",
"denodeify": "^1.2.1",
+ "disc": "^1.3.2",
"dnode": "^1.2.2",
"end-of-stream": "^1.1.0",
"ensnare": "^1.0.0",
@@ -64,6 +66,7 @@
"menu-droppo": "^1.1.0",
"metamask-logo": "^2.1.2",
"mississippi": "^1.2.0",
+ "mkdirp": "^0.5.1",
"multiplex": "^6.7.0",
"once": "^1.3.3",
"ping-pong-stream": "^1.0.0",