From 168b4c5bc034367912f32bad6706cc91987d1085 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 1 Sep 2016 15:01:45 -0700 Subject: [PATCH 1/6] Install deps. Fix chrome/firefox typo. --- gulpfile.js | 8 +++++--- package.json | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index dac6cce3e..40ae6f203 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -16,6 +16,8 @@ var eslint = require('gulp-eslint') var fs = require('fs') var path = require('path') var manifest = require('./app/manifest.json') +var gulpif = require('gulp-if') +var replace = require('gulp-replace') // browser reload @@ -72,8 +74,8 @@ gulp.task('copy:root', copyTask({ pattern: '/*', })) -gulp.task('manifest:cleanup', function() { - return gulp.src('./dist/firefox/manifest.json') +gulp.task('manifest:chrome', function() { + return gulp.src('./dist/chrome/manifest.json') .pipe(jsoneditor(function(json) { delete json.applications return json @@ -81,7 +83,7 @@ gulp.task('manifest:cleanup', function() { .pipe(gulp.dest('./dist/chrome', { overwrite: true })) }) -gulp.task('copy', gulp.series(gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root'), 'manifest:cleanup')) +gulp.task('copy', gulp.series(gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root'), 'manifest:chrome')) gulp.task('copy:watch', function(){ gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy')) }) diff --git a/package.json b/package.json index fdf6c822e..63754f417 100644 --- a/package.json +++ b/package.json @@ -94,8 +94,10 @@ "del": "^2.2.0", "gulp": "github:gulpjs/gulp#4.0", "gulp-brfs": "^0.1.0", + "gulp-if": "^2.0.1", "gulp-json-editor": "^2.2.1", "gulp-livereload": "^3.8.1", + "gulp-replace": "^0.5.4", "gulp-sourcemaps": "^1.6.0", "gulp-util": "^3.0.7", "gulp-watch": "^4.3.5", From c02be4fa66a037bd23fb5d51759b6d4a7486bf6e Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Thu, 1 Sep 2016 15:19:31 -0700 Subject: [PATCH 2/6] Add production flag. Conditionally copy reload based on production. --- gulpfile.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 40ae6f203..2f2722a3b 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,6 +19,8 @@ var manifest = require('./app/manifest.json') var gulpif = require('gulp-if') var replace = require('gulp-replace') +var production = false + // browser reload gulp.task('dev:reload', function() { @@ -83,7 +85,20 @@ gulp.task('manifest:chrome', function() { .pipe(gulp.dest('./dist/chrome', { overwrite: true })) }) -gulp.task('copy', gulp.series(gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root'), 'manifest:chrome')) +gulp.task('manifest:production', function() { + return gulp.src([ + './dist/firefox/manifest.json', + './dist/chrome/manifest.json', + './dist/edge/manifest.json', + ],{base: './dist/'}) + .pipe(gulpif(production,jsoneditor(function(json) { + json.background.scripts = ["scripts/background.js"] + return json + }))) + .pipe(gulp.dest('./dist/', { overwrite: true })) +}) + +gulp.task('copy', gulp.series(gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root'), 'manifest:production', 'manifest:chrome')) gulp.task('copy:watch', function(){ gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy')) }) From b4334a72b45d18c4985c1882f5da7ad4a1b907df Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 2 Sep 2016 14:00:36 -0700 Subject: [PATCH 3/6] Refactor for spreading. Add conditionals for livereload. --- gulpfile.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 2f2722a3b..ad87586e5 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,7 +19,7 @@ var manifest = require('./app/manifest.json') var gulpif = require('gulp-if') var replace = require('gulp-replace') -var production = false +var production = gutil.env.production // browser reload @@ -98,7 +98,20 @@ gulp.task('manifest:production', function() { .pipe(gulp.dest('./dist/', { overwrite: true })) }) -gulp.task('copy', gulp.series(gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root'), 'manifest:production', 'manifest:chrome')) +const staticFiles = [ + 'locales', + 'images', + 'fonts', + 'root' +] + +var copyStrings = staticFiles.map(staticFile => `copy:${staticFile}`) + +if (!production) { + copyStrings.push('copy:`reload`') +} + +gulp.task('copy', gulp.series(gulp.parallel(...copyStrings), 'manifest:production', 'manifest:chrome')) gulp.task('copy:watch', function(){ gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy')) }) @@ -132,14 +145,18 @@ const jsFiles = [ 'popup', ] +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', gulp.parallel('dev:js:inpage','dev:js:contentscript','dev:js:background','dev:js:popup')) +gulp.task('dev:js', gulp.parallel(...jsDevStrings)) + +gulp.task('build:js', gulp.parallel(...jsBuildStrings)) -gulp.task('build:js', gulp.parallel('build:js:inpage','build:js:contentscript','build:js:background','build:js:popup')) // clean dist @@ -169,6 +186,7 @@ gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox', 'zip:edge')) // high level tasks gulp.task('dev', gulp.series('dev:js', 'copy', gulp.parallel('copy:watch', 'dev:reload'))) + gulp.task('build', gulp.series('clean', gulp.parallel('build:js', 'copy'))) gulp.task('dist', gulp.series('build', 'zip')) @@ -187,7 +205,7 @@ function copyTask(opts){ destinations.forEach(function(destination) { stream = stream.pipe(gulp.dest(destination)) }) - stream.pipe(livereload()) + stream.pipe(gulpif(production,livereload())) return stream } @@ -228,7 +246,7 @@ function bundleTask(opts) { .pipe(gulp.dest('./dist/firefox/scripts')) .pipe(gulp.dest('./dist/chrome/scripts')) .pipe(gulp.dest('./dist/edge/scripts')) - .pipe(livereload()) + .pipe(gulpif(!production,livereload())) ) } From 2d0077d5c67e5861628e865c1477878f3277d10d Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 2 Sep 2016 14:15:00 -0700 Subject: [PATCH 4/6] Changelog add and rename vars. --- CHANGELOG.md | 1 + gulpfile.js | 12 ++++++------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e705adef..d608fd976 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - Fix bug where provider menu did not allow switching to custom network from a custom network. - Sending a transaction from within MetaMask no longer triggers a popup. +- The ability to build without livereload features (such as for production) can be enabled with the gulp --disableLiveReload ## 2.10.0 2016-08-29 diff --git a/gulpfile.js b/gulpfile.js index ad87586e5..3d28e7198 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,7 +19,7 @@ var manifest = require('./app/manifest.json') var gulpif = require('gulp-if') var replace = require('gulp-replace') -var production = gutil.env.production +var disableLiveReload = gutil.env.disableLiveReload // browser reload @@ -91,7 +91,7 @@ gulp.task('manifest:production', function() { './dist/chrome/manifest.json', './dist/edge/manifest.json', ],{base: './dist/'}) - .pipe(gulpif(production,jsoneditor(function(json) { + .pipe(gulpif(disableLiveReload,jsoneditor(function(json) { json.background.scripts = ["scripts/background.js"] return json }))) @@ -107,8 +107,8 @@ const staticFiles = [ var copyStrings = staticFiles.map(staticFile => `copy:${staticFile}`) -if (!production) { - copyStrings.push('copy:`reload`') +if (!disableLiveReload) { + copyStrings.push('copy:reload') } gulp.task('copy', gulp.series(gulp.parallel(...copyStrings), 'manifest:production', 'manifest:chrome')) @@ -205,7 +205,7 @@ function copyTask(opts){ destinations.forEach(function(destination) { stream = stream.pipe(gulp.dest(destination)) }) - stream.pipe(gulpif(production,livereload())) + stream.pipe(gulpif(disableLiveReload,livereload())) return stream } @@ -246,7 +246,7 @@ function bundleTask(opts) { .pipe(gulp.dest('./dist/firefox/scripts')) .pipe(gulp.dest('./dist/chrome/scripts')) .pipe(gulp.dest('./dist/edge/scripts')) - .pipe(gulpif(!production,livereload())) + .pipe(gulpif(!disableLiveReload,livereload())) ) } From f9f821e72650046466b9c1f0694a1cdb0c1e637c Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 2 Sep 2016 14:15:15 -0700 Subject: [PATCH 5/6] Changelog add. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d608fd976..1f414e0fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ - Fix bug where provider menu did not allow switching to custom network from a custom network. - Sending a transaction from within MetaMask no longer triggers a popup. -- The ability to build without livereload features (such as for production) can be enabled with the gulp --disableLiveReload +- The ability to build without livereload features (such as for production) can be enabled with the gulp --disableLiveReload flag. ## 2.10.0 2016-08-29 From be0c605556a21a824bb841f80da58220b8b32058 Mon Sep 17 00:00:00 2001 From: Kevin Serrano Date: Fri, 2 Sep 2016 14:42:20 -0700 Subject: [PATCH 6/6] Fix boolean. --- gulpfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gulpfile.js b/gulpfile.js index 3d28e7198..9f1acbf67 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -205,7 +205,7 @@ function copyTask(opts){ destinations.forEach(function(destination) { stream = stream.pipe(gulp.dest(destination)) }) - stream.pipe(gulpif(disableLiveReload,livereload())) + stream.pipe(gulpif(!disableLiveReload,livereload())) return stream }