-
-
Notifications
You must be signed in to change notification settings - Fork 53
/
gulpfile.js
executable file
·84 lines (75 loc) · 2.07 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
76
77
78
79
80
81
82
83
84
// Script: gulpfile.js
// by: William C. Canin
let gulp = require('gulp');
let uglify = require('gulp-uglify');
let imagemin = require('gulp-imagemin');
let htmlmin = require('gulp-htmlmin');
let del = require('del');
// function clean objects caches
function clean_objects() {
var objs = [
'node_modules',
'cache',
'vendor',
'package-lock.json',
'Gemfile.lock'
]
return del(objs)
}
// function postinstall for copy files statics
function postinstall_statics() {
return gulp
.src(['node_modules/jquery/dist/jquery.min.js',
'node_modules/popper.js/dist/umd/popper.min.js',
'node_modules/popper.js/dist/umd/popper.min.js.map',
'node_modules/bootstrap/dist/js/bootstrap.min.js',
'node_modules/bootstrap/dist/js/bootstrap.min.js.map'])
.pipe(gulp.dest('assets/vendor/js'))
}
// function minify javascripts
function javascripts() {
return gulp
.src('public/assets/js/**/*.js')
.pipe(uglify())
.pipe(gulp.dest('public/assets/js'))
}
// function minify html
function html_minify() {
return gulp
.src('public/**/*.html')
.pipe(htmlmin({ collapseWhitespace: true, removeComments: true }))
.pipe(gulp.dest('public'))
}
// function optimize images
function images_minify() {
return gulp
.src('public/assets/images/**/*')
.pipe(
imagemin([
imagemin.gifsicle({ interlaced: true }),
imagemin.mozjpeg({ progressive: true }),
imagemin.optipng({ optimizationLevel: 5 }),
imagemin.svgo({
plugins: [
{
removeViewBox: true,
collapseGroups: false
}
]
})
])
)
.pipe(gulp.dest('public/assets/images'));
}
// task build
const build = gulp.series(gulp.parallel(html_minify,
javascripts,
images_minify));
// export tasks
exports.postinstall = postinstall_statics;
exports.images = images_minify;
exports.js = javascripts;
exports.html = html_minify;
exports.build = build;
exports.clean = clean_objects;
exports.default = build;