forked from g0e/ccd3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
46 lines (39 loc) · 1.23 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
const {src, dest, watch, parallel, series} = require('gulp');
const babel = require('gulp-babel');
const eslint = require('gulp-eslint');
const terser = require('gulp-terser');
const rename = require('gulp-rename');
const cleanCss = require('gulp-clean-css');
const buildJs = () => src('./src/**/*.js')
.pipe(eslint())
.pipe(eslint.failOnError())
.pipe(babel())
.pipe(dest('./dist/'));
const watchJs = () => watch('./src/**/*.js', buildJs);
const minifyJs = () => src(['./dist/**/*.js', '!./dist/**/*.min.js'])
.pipe(eslint())
.pipe(eslint.failOnError())
.pipe(terser({
mangle: false,
}))
.pipe(rename({extname: '.min.js'}))
.pipe(dest('./dist/'));
const buildCss = () => src('./src/**/*.css')
.pipe(dest('./dist/'));
const watchCss = () => watch('./src/**/*.css', buildCss);
const minifyCss = () => src(['./dist/**/*.css', '!./dist/**/*.min.css'])
.pipe(rename({extname: '.min.css'}))
.pipe(cleanCss())
.pipe(dest('./dist/'));
module.exports = {
buildJs,
buildCss,
build: parallel(buildJs, buildCss),
watchJs,
watchCss,
watch: parallel(watchJs, watchCss),
minifyJs,
minifyCss,
minify: parallel(minifyCss, minifyJs),
default: series(parallel(buildJs, buildCss), parallel(minifyCss, minifyJs)),
};