-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
60 lines (49 loc) · 1.39 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var gulp = require('gulp'),
cleanCSS = require('gulp-clean-css'),
concat = require('gulp-concat'),
less = require('gulp-less'),
rename = require('gulp-rename'),
uglify = require('gulp-uglify'),
gutil = require('gulp-util');
// Error handling to prevent watch task to fail silently without restarting.
var onError = function(err) {
gutil.log(gutil.colors.red('ERROR', err.plugin), err.message);
gutil.beep();
new gutil.PluginError(err.plugin, err, {showStack: true})
this.emit('end');
};
// Concat minify and prefix all required js files.
gulp.task('js', function () {
var uglifyOptions = {
compress: {
hoist_funs: false,
hoist_vars: false
},
output: {
comments: /(license|copyright)/i,
max_line_len: 500
}
};
return gulp.src('js/lightbox.js')
.pipe(uglify(uglifyOptions))
.pipe(concat('lightbox.min.js'))
.pipe(gulp.dest('dist'));
});
// Compile, minify and prefix alpha.less.
gulp.task('less', function () {
var cleanCSSOptions = {
format: { wrapAt: 500 },
rebase: false
};
return gulp.src('less/lightbox.less')
.pipe(less())
.on('error', onError)
.pipe(cleanCSS(cleanCSSOptions))
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('dist'));
});
gulp.task('watch', function () {
gulp.watch('less/lightbox.less', gulp.series('less'));
gulp.watch('js/lightbox.js', gulp.series('js'));
});
gulp.task('default', gulp.series('less', 'js'));