From f07bb207b3e0d84c60f9952f18cce386825aec16 Mon Sep 17 00:00:00 2001 From: Valentin Marmonier Date: Tue, 9 Aug 2016 12:42:24 +0200 Subject: [PATCH] add a watch toggle in package.json --- gulp/tasks/html.js | 23 ++++++++++++----------- gulp/tasks/scripts.js | 7 +++++-- gulp/tasks/styles.js | 6 ++++-- gulp/utils/pkg.js | 3 ++- package.json | 1 + 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/gulp/tasks/html.js b/gulp/tasks/html.js index d7ffa6e..4097a6c 100644 --- a/gulp/tasks/html.js +++ b/gulp/tasks/html.js @@ -24,14 +24,15 @@ gulp.task('html', function () { .pipe(gulp.dest('./')) .pipe(notify({ title: 'Html', message: 'Success', sound: 'Morse' })); - gulp.watch([ - './app/src/**/*.html', - '!./app/src/{vendor,vendor/**}' - ], function (file) { - gulp.src(file.path) - .pipe(pkg.debug || false ? gutil.noop() : minify()) - .pipe(gulp.dest('./')) - .pipe(notify({ title: 'Html', message: 'Success', sound: 'Morse' })); - }); - -}); \ No newline at end of file + if(pkg.watch) { + gulp.watch([ + './app/src/**/*.html', + '!./app/src/{vendor,vendor/**}' + ], function (file) { + gulp.src(file.path) + .pipe(pkg.debug || false ? gutil.noop() : minify()) + .pipe(gulp.dest('./')) + .pipe(notify({ title: 'Html', message: 'Success', sound: 'Morse' })); + }); + } +}); diff --git a/gulp/tasks/scripts.js b/gulp/tasks/scripts.js index b433f73..57d3e73 100644 --- a/gulp/tasks/scripts.js +++ b/gulp/tasks/scripts.js @@ -17,7 +17,10 @@ function scripts (entry, output, message) { var outputDetails = splitPath(output); - var bundler = watchify(browserify(entry, { debug: pkg.debug })); + var bundler = pkg.watch + ? watchify(browserify(entry, { debug: pkg.debug })) + : browserify({ entries: [entry] }) + bundler.on('update', bundle); function bundle() { @@ -54,4 +57,4 @@ gulp.task('scripts:2D', function () { ); }); -gulp.task('scripts', ['scripts:2D', 'scripts:3D']); \ No newline at end of file +gulp.task('scripts', ['scripts:2D', 'scripts:3D']); diff --git a/gulp/tasks/styles.js b/gulp/tasks/styles.js index 5ce199c..fe1857a 100644 --- a/gulp/tasks/styles.js +++ b/gulp/tasks/styles.js @@ -31,7 +31,9 @@ function styles (input, output, message) { process(); - gulp.watch('./app/src/less/**/*.less', process); + if(pkg.watch) { + gulp.watch('./app/src/less/**/*.less', process); + } } gulp.task('styles:3D', function () { @@ -50,4 +52,4 @@ gulp.task('styles:2D', function () { ); }); -gulp.task('styles', ['styles:2D', 'styles:3D']); \ No newline at end of file +gulp.task('styles', ['styles:2D', 'styles:3D']); diff --git a/gulp/utils/pkg.js b/gulp/utils/pkg.js index e854ac7..2ae3b84 100644 --- a/gulp/utils/pkg.js +++ b/gulp/utils/pkg.js @@ -18,6 +18,7 @@ var pkg = (function () { return { debug: data.debug || false, + watch: data.watch || false, vendor: data.browser || {} } } @@ -33,4 +34,4 @@ var pkg = (function () { }; })(); -module.exports = pkg.getInstance(); \ No newline at end of file +module.exports = pkg.getInstance(); diff --git a/package.json b/package.json index d1db900..a9721d8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "2015", "debug": false, + "watch": false, "devDependencies": { "browserify": "^6.3.2", "browserify-shim": "^3.8.0",