Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add a watch toggle in package.json
  • Loading branch information
Valentin Marmonier committed Aug 9, 2016
1 parent ca89017 commit f07bb20
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 16 deletions.
23 changes: 12 additions & 11 deletions gulp/tasks/html.js
Expand Up @@ -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' }));
});

});
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' }));
});
}
});
7 changes: 5 additions & 2 deletions gulp/tasks/scripts.js
Expand Up @@ -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() {
Expand Down Expand Up @@ -54,4 +57,4 @@ gulp.task('scripts:2D', function () {
);
});

gulp.task('scripts', ['scripts:2D', 'scripts:3D']);
gulp.task('scripts', ['scripts:2D', 'scripts:3D']);
6 changes: 4 additions & 2 deletions gulp/tasks/styles.js
Expand Up @@ -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 () {
Expand All @@ -50,4 +52,4 @@ gulp.task('styles:2D', function () {
);
});

gulp.task('styles', ['styles:2D', 'styles:3D']);
gulp.task('styles', ['styles:2D', 'styles:3D']);
3 changes: 2 additions & 1 deletion gulp/utils/pkg.js
Expand Up @@ -18,6 +18,7 @@ var pkg = (function () {

return {
debug: data.debug || false,
watch: data.watch || false,
vendor: data.browser || {}
}
}
Expand All @@ -33,4 +34,4 @@ var pkg = (function () {
};
})();

module.exports = pkg.getInstance();
module.exports = pkg.getInstance();
1 change: 1 addition & 0 deletions package.json
@@ -1,6 +1,7 @@
{
"name": "2015",
"debug": false,
"watch": false,
"devDependencies": {
"browserify": "^6.3.2",
"browserify-shim": "^3.8.0",
Expand Down

0 comments on commit f07bb20

Please sign in to comment.