forked from Lidemy/lazy-hackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
28 lines (24 loc) · 775 Bytes
/
gulpfile.js
File metadata and controls
28 lines (24 loc) · 775 Bytes
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
const gulp = require('gulp');
const htmlmin = require('gulp-htmlmin');
const cleanCSS = require('gulp-clean-css');
const terser = require('gulp-terser');
/* --- 壓縮 HTML --- */
gulp.task('minify-html', () => {
return gulp
.src('*.html')
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(gulp.dest('./dist'));
});
/* --- 壓縮 CSS --- */
gulp.task('minify-css', () => {
return gulp
.src('src/css/*.css')
.pipe(cleanCSS({ compatibility: '*' }))
.pipe(gulp.dest('dist/css'));
});
/* --- 壓縮 JavaScript --- */
gulp.task('minify-js', () => {
return gulp.src('src/js/*.js').pipe(terser()).pipe(gulp.dest('dist/js'));
});
/* --- 同步執行全部任務 --- */
gulp.task('default', gulp.parallel('minify-html', 'minify-css', 'minify-js'));