From 4715a55d0f59bce76e7a5681cc878802ca968852 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 28 Jul 2016 11:58:37 -0700 Subject: [PATCH 1/2] Update readme node version --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aeb6490d2..4c348b56c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ ## Building locally - - Install [Node.js](https://nodejs.org/en/) version 6 or later. + - Install [Node.js](https://nodejs.org/en/) version 6.3.1 or later. - Install local dependencies with `npm install`. - Install gulp globally with `npm install -g gulp-cli`. - Build the project to the `./dist/` folder with `gulp build`. From bdd2752cc778760da798163cc94975b5a9cece3c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Thu, 28 Jul 2016 12:59:37 -0700 Subject: [PATCH 2/2] Fix some gulp task issues I know, I've been fixing up the gulp scripts all week. I keep fixing one thing then breaking another. In this commit, I fix some issues with some previous approaches. I no longer try to do the copying to `chrome` after `firefox`, I simply stream to both during copy and build tasks, and that logic is reused during dev and build tasks. The `copyTask` function now supports an array of `destinations`, that allows piping to multiple destinations, which is pretty cool. The `manifest:cleanup` task that chrome requires is now just part of the `copy` task, so we don't have to remember it everywhere we copy. So obvious it's like why only now. --- gulpfile.js | 49 +++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 96e5e11c7..aeaf3e674 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -31,26 +31,42 @@ gulp.task('dev:reload', function() { gulp.task('copy:locales', copyTask({ source: './app/_locales/', - destination: './dist/firefox/_locales', + destinations: [ + './dist/firefox/_locales', + './dist/chrome/_locales', + ] })) gulp.task('copy:images', copyTask({ source: './app/images/', - destination: './dist/firefox/images', + destinations: [ + './dist/firefox/images', + './dist/chrome/images', + ], })) gulp.task('copy:fonts', copyTask({ source: './app/fonts/', - destination: './dist/firefox/fonts', + destinations: [ + './dist/firefox/fonts', + './dist/chrome/fonts', + ], })) gulp.task('copy:reload', copyTask({ source: './app/scripts/', - destination: './dist/firefox/scripts', + destinations: [ + './dist/firefox/scripts', + './dist/chrome/scripts', + ], pattern: '/chromereload.js', })) gulp.task('copy:root', copyTask({ source: './app/', - destination: './dist/firefox', + destinations: [ + './dist/firefox', + './dist/chrome', + ], pattern: '/*', })) + gulp.task('manifest:cleanup', function() { return gulp.src('./dist/firefox/manifest.json') .pipe(jsoneditor(function(json) { @@ -59,12 +75,8 @@ gulp.task('manifest:cleanup', function() { })) .pipe(gulp.dest('./dist/chrome', { overwrite: true })) }) -gulp.task('copy:chrome', gulp.series( -copyTask({ - source: './dist/firefox', - destination: './dist/chrome', -}), 'manifest:cleanup')) -gulp.task('copy', gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root')) + +gulp.task('copy', gulp.series(gulp.parallel('copy:locales','copy:images','copy:fonts','copy:reload','copy:root'), 'manifest:cleanup')) gulp.task('copy:watch', function(){ gulp.watch(['./app/{_locales,images}/*', './app/scripts/chromereload.js', './app/*.{html,json}'], gulp.series('copy')) }) @@ -130,7 +142,7 @@ gulp.task('zip', gulp.parallel('zip:chrome', 'zip:firefox')) // high level tasks gulp.task('dev', gulp.series('dev:js', 'copy', gulp.parallel('copy:watch', 'dev:reload'))) -gulp.task('build', gulp.series('clean', 'build:js', 'copy')) +gulp.task('build', gulp.series('clean', gulp.parallel('build:js', 'copy'))) gulp.task('dist', gulp.series('build', 'zip')) // task generators @@ -138,18 +150,19 @@ gulp.task('dist', gulp.series('build', 'zip')) function copyTask(opts){ var source = opts.source var destination = opts.destination + var destinations = opts.destinations || [ destination ] var pattern = opts.pattern || '/**/*' return performCopy function performCopy(){ - return ( + let stream = gulp.src(source + pattern, { base: source }) + destinations.forEach(function(destination) { + stream = stream.pipe(gulp.dest(destination)) + }) + stream.pipe(livereload()) - gulp.src(source + pattern, { base: source }) - .pipe(gulp.dest(destination)) - .pipe(livereload()) - - ) + return stream } }