-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
42 lines (36 loc) · 1.3 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
const gulp = require('gulp');
const minifyHTML = require('gulp-htmlmin');
const minifyJS = require('gulp-uglify-es').default;
const minifyCSS = require('gulp-clean-css');
const sass = require('gulp-sass')(require('sass'));
const imagemin = require('gulp-image');
const rename = require('gulp-rename');
gulp.task('minify-html', () => {
return gulp.src('lib/html/*.html')
.pipe(minifyHTML({ collapseWhitespace: true }))
.pipe(gulp.dest('public/html'));
});
gulp.task('minify-js', () => {
return gulp.src('lib/js/*.js')
.pipe(minifyJS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('public/js'));
});
gulp.task('minify-css', () => {
return gulp.src('lib/scss/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(minifyCSS())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest('public/css'));
});
gulp.task('minify-image', () => {
return gulp.src('public/images/*')
.pipe(imagemin())
.pipe(gulp.dest('public/images'));
});
gulp.task('watch', () => {
gulp.watch('lib/html/*.html', gulp.series('minify-html'));
gulp.watch('lib/js/*.js', gulp.series('minify-js'));
gulp.watch('lib/scss/**/*.scss', gulp.series('minify-css'));
});
gulp.task('default', gulp.series('minify-html', 'minify-js', 'minify-css'));