-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
75 lines (65 loc) · 2.18 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
'use strict'
const gulp = require('gulp');
const ejs = require('gulp-minify-ejs');
const purgecss = require('gulp-purgecss');
const sourcemaps = require('gulp-sourcemaps');
const css = require('gulp-clean-css');
const imagemin = require('gulp-imagemin');
const uglify = require('gulp-uglify-es').default;
const ejsGulp = function() {
return gulp.src(['src/views/**/*.ejs', 'src/views/*.html'])
.pipe(ejs())
//.pipe(rename({suffix:".min"}))
.pipe(gulp.dest('views/'))
}
const imagesGulp = function() {
return gulp.src('src/assets/img/**')
.pipe(imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.mozjpeg({ quality: 75, progressive: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
plugins: [
{ removeViewBox: true },
{ cleanupIDs: false }
]
})
]))
.pipe(gulp.dest('public/img'));
};
const iconsGulp = function() {
return gulp.src('src/assets/icon/**')
.pipe(imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.mozjpeg({ quality: 75, progressive: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
plugins: [
{ removeViewBox: true },
{ cleanupIDs: false }
]
})
]))
.pipe(gulp.dest('public/icon'));
};
const purgeCss = function() {
return gulp.src('src/assets/css/*.css')
.pipe(purgecss({
content: ['src/views/**/*.ejs'],
whitelistPatterns: [/active$/],
whitelistPatternsChildren: [/active$/]
}))
.pipe(sourcemaps.init())
.pipe(css())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('public/css/'))
};
const jsGulp = function() {
return gulp.src('src/assets/js/*.js')
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('public/js'));
};
exports.build = gulp.parallel(ejsGulp, purgeCss, imagesGulp, jsGulp, iconsGulp);
// exports.watch = gulp.parallel(server, watch);