-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
43 lines (40 loc) · 1.11 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// minify dorm.js using closure compiler
var gulp = require('gulp')
var plumber = require('gulp-plumber')
var notify = require('gulp-notify')
var compiler = require('google-closure-compiler-js').gulp()
var options = {
base: './',
input: 'dorm.js',
output: 'dorm.min.js',
notification: {
title: 'Dorm.js compilation',
success: 'Minified successfully',
error: '<%= error.message %>',
},
}
gulp.task('compile', function () {
return gulp.src(options.input, {base: options.base})
.pipe(plumber({errorHandler: function (error) {
notify.onError({
title: options.notification.title,
message: options.notification.error,
})(error)
this.emit('end')
}}))
.pipe(compiler({
compilationLevel: 'SIMPLE',
warningLevel: 'DEFAULT',
jsOutputFile: options.output,
createSourceMap: false,
}))
.pipe(gulp.dest(options.base))
.pipe(notify({
title: options.notification.title,
message: options.notification.success,
}))
})
gulp.task('watch', function () {
gulp.watch('dorm.js', ['compile'])
})
gulp.task('default', ['compile', 'watch'])