-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.js
40 lines (33 loc) · 1.26 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
const gulp = require('gulp')
const terser = require('gulp-terser');
const imagemin = require('gulp-imagemin');
const del = require('del');
gulp.task('copy', async function () {
gulp.src('./src/views/*.html').pipe(gulp.dest('./dist/views'))
gulp.src('./src/css/*.css').pipe(gulp.dest('./dist/css'))
gulp.src('./src/lib/*').pipe(gulp.dest('./dist/lib'))
gulp.src('./src/manifest.json').pipe(gulp.dest('./dist'))
})
gulp.task('clean', async function () {
del(['./dist/*'])
})
gulp.task('uglify', async function () {
gulp.src('./src/js/*.js')
.pipe(terser())
.pipe(gulp.dest('./dist/js'));
})
gulp.task('compress-img', async function () {
gulp.src('./src/images/*')
.pipe(imagemin())
.pipe(gulp.dest('./dist/images'))
})
gulp.task('build', gulp.series('copy', 'uglify', 'compress-img'))
gulp.task('watch', async function () {
gulp.watch('./src/views/*.html', gulp.series('copy'))
gulp.watch('./src/css/*.css', gulp.series('copy'))
gulp.src('./src/lib/*').pipe(gulp.dest('./dist/lib'))
gulp.watch('./src/manifest.json', gulp.series('copy'))
gulp.watch('./src/js/*.js', gulp.series('uglify'))
gulp.watch('./src/images/*', gulp.series('compress-img'))
})
gulp.task('default', gulp.series('build', 'watch'))