Adding error notification to gulp tasks
This commit is contained in:
parent
3c5c1579e2
commit
8a30c31243
@ -14,7 +14,6 @@
|
|||||||
"sourcemap": true
|
"sourcemap": true
|
||||||
},
|
},
|
||||||
"browserify": {
|
"browserify": {
|
||||||
"entries": ["./main.js"],
|
|
||||||
"basedir": "./src/js",
|
"basedir": "./src/js",
|
||||||
"debug": true
|
"debug": true
|
||||||
}
|
}
|
||||||
|
29
gulpfile.js
29
gulpfile.js
@ -1,6 +1,14 @@
|
|||||||
var gulp = require('gulp'),
|
var gulp = require('gulp'),
|
||||||
|
notify = require('gulp-notify'),
|
||||||
|
plumber = require('gulp-plumber'),
|
||||||
config = require('./config');
|
config = require('./config');
|
||||||
|
|
||||||
|
function errorHandler() {
|
||||||
|
return plumber({
|
||||||
|
errorHandler: notify.onError('Error: <%= error.message %>')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
gulp.task('default', ['server'], function() {
|
gulp.task('default', ['server'], function() {
|
||||||
gulp.watch(config.globs.other, ['static']);
|
gulp.watch(config.globs.other, ['static']);
|
||||||
gulp.watch([config.globs.html, config.templateFile], ['markup']);
|
gulp.watch([config.globs.html, config.templateFile], ['markup']);
|
||||||
@ -14,6 +22,7 @@ gulp.task('server', ['build'], function() {
|
|||||||
|
|
||||||
watch('./build/**/*', { name: 'Server' })
|
watch('./build/**/*', { name: 'Server' })
|
||||||
.pipe(connect.reload());
|
.pipe(connect.reload());
|
||||||
|
|
||||||
return connect.server({
|
return connect.server({
|
||||||
root: './build',
|
root: './build',
|
||||||
livereload: true
|
livereload: true
|
||||||
@ -24,6 +33,7 @@ gulp.task('build', ['static', 'markup', 'compass', 'browserify']);
|
|||||||
|
|
||||||
gulp.task('static', function() {
|
gulp.task('static', function() {
|
||||||
return gulp.src(config.globs.other)
|
return gulp.src(config.globs.other)
|
||||||
|
.pipe(errorHandler())
|
||||||
.pipe(gulp.dest('./build'));
|
.pipe(gulp.dest('./build'));
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -31,6 +41,7 @@ gulp.task('markup', function() {
|
|||||||
var wrap = require('gulp-wrap');
|
var wrap = require('gulp-wrap');
|
||||||
|
|
||||||
return gulp.src(config.globs.html)
|
return gulp.src(config.globs.html)
|
||||||
|
.pipe(errorHandler())
|
||||||
.pipe(wrap({ src: config.templateFile }))
|
.pipe(wrap({ src: config.templateFile }))
|
||||||
.pipe(gulp.dest('./build'));
|
.pipe(gulp.dest('./build'));
|
||||||
});
|
});
|
||||||
@ -39,20 +50,24 @@ gulp.task('compass', function() {
|
|||||||
var compass = require('gulp-compass');
|
var compass = require('gulp-compass');
|
||||||
|
|
||||||
return gulp.src(config.globs.sass)
|
return gulp.src(config.globs.sass)
|
||||||
|
.pipe(errorHandler())
|
||||||
.pipe(compass(config.compass));
|
.pipe(compass(config.compass));
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('browserify', function() {
|
gulp.task('browserify', function() {
|
||||||
var browserify = require('browserify'),
|
var browserify = require('browserify'),
|
||||||
es6ify = require('es6ify'),
|
es6ify = require('es6ify'),
|
||||||
source = require('vinyl-source-stream');
|
tap = require('gulp-tap');
|
||||||
bundler = browserify(config.browserify);
|
|
||||||
|
|
||||||
bundler.add(es6ify.runtime);
|
return gulp.src('./src/js/main.js', { read: false })
|
||||||
|
.pipe(errorHandler())
|
||||||
|
.pipe(tap(function(file) {
|
||||||
|
var bundler = browserify(config.browserify);
|
||||||
|
|
||||||
|
bundler.add([file.path, es6ify.runtime]);
|
||||||
bundler.transform(es6ify);
|
bundler.transform(es6ify);
|
||||||
|
|
||||||
return bundler
|
file.contents = bundler.bundle();
|
||||||
.bundle()
|
}))
|
||||||
.pipe(source('js/main.js'))
|
.pipe(gulp.dest('./build/js'));
|
||||||
.pipe(gulp.dest('./build'));
|
|
||||||
});
|
});
|
||||||
|
@ -15,8 +15,10 @@
|
|||||||
"gulp": "^3.8.10",
|
"gulp": "^3.8.10",
|
||||||
"gulp-compass": "^2.0.3",
|
"gulp-compass": "^2.0.3",
|
||||||
"gulp-connect": "^2.2.0",
|
"gulp-connect": "^2.2.0",
|
||||||
|
"gulp-notify": "^2.0.1",
|
||||||
|
"gulp-plumber": "^0.6.6",
|
||||||
|
"gulp-tap": "^0.1.3",
|
||||||
"gulp-watch": "^2.0.0",
|
"gulp-watch": "^2.0.0",
|
||||||
"gulp-wrap": "^0.5.0",
|
"gulp-wrap": "^0.5.0"
|
||||||
"vinyl-source-stream": "^1.0.0"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user