-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
48 lines (42 loc) · 1.08 KB
/
gulpfile.js
File metadata and controls
48 lines (42 loc) · 1.08 KB
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
44
45
46
47
48
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var gzip = require('gulp-gzip');
var through = require('through2');
var jsBundler = require('js-bundler');
var notifier = require('node-notifier');
var production = process.argv.indexOf('--production') !== -1;
function js(options) {
return jsBundler(options).on('error', function(err) {
notifier.notify({
title: 'Error',
message: err,
sound: true
});
console.error(err.stack || err);
this.emit('end');
});
}
gulp.task('js', function() {
return gulp.src('./livestyle-*.js')
.pipe(js({
sourceMap: !production,
detectGlobals: false,
global: true
}))
.pipe(production ? uglify() : through.obj())
.pipe(gulp.dest('./out'));
});
gulp.task('full', ['build'], function() {
return gulp.src('**/*.{html,css,js,ico}', {cwd: './out'})
.pipe(gzip({
threshold: '1kb',
gzipOptions: {level: 7}
}))
.pipe(gulp.dest('./out'));
});
gulp.task('watch', function() {
jsBundler.watch({sourceMap: true});
gulp.watch(['./livestyle-*.js'], ['js']);
});
gulp.task('build', ['js']);
gulp.task('default', ['build']);