-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
44 lines (36 loc) · 965 Bytes
/
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
const gulp = require('gulp');
const cleanCSS = require('gulp-clean-css');
const terser = require('gulp-terser');
const rename = require('gulp-rename');
const cssSrc = [
'assets/css/**/*.css',
'!assets/css/vendor/**/*.css',
'!assets/css/**/*.min.css',
];
const jsSrc = [
'assets/js/**/*.js',
'!assets/js/vendor/**/*.js',
'!assets/js/**/*.min.js',
];
gulp.task('minify-css', () => {
return gulp.src(cssSrc)
.pipe(cleanCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest((file) => {
return file.base;
}));
});
gulp.task('minify-js', () => {
return gulp.src(jsSrc)
.pipe(terser())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest((file) => {
return file.base;
}));
});
gulp.task('watch', () => {
gulp.watch(cssSrc, gulp.series('minify-css'));
gulp.watch(jsSrc, gulp.series('minify-js'));
});
gulp.task('build', gulp.series('minify-css', 'minify-js'));
gulp.task('default', gulp.series('minify-css', 'minify-js', 'watch'));