-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
113 lines (99 loc) · 2.12 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
const
destination = './docs/',
gulp = require('gulp'),
minifyHTML = require('gulp-html-minimizer'),
minifyJS = require('gulp-terser'),
minifyIMG = require('gulp-imagemin'),
shell = require('child_process').exec
;
function reset() {
return shell(`npx del-cli ${destination}`);
}
function redirect() {
return gulp.src('./.netlify/_redirects')
.pipe(gulp.dest(destination));
}
function eleventy() {
return shell(`npx @11ty/eleventy --output="${destination}"`);
}
function css() {
return shell(`npx sass site/Styles:${destination}css --style=compressed --no-source-map`);
}
function html() {
return gulp.src(destination + '**/*.html')
.pipe(minifyHTML({
collapseBooleanAttributes: true,
collapseInlineTagWhitespace: true,
collapseWhitespace: true,
conservativeCollapse: true,
minifyCSS: true,
minifyJS: true,
preserveLineBreaks: true,
removeComments: true,
removeEmptyAttributes: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
}))
.pipe(gulp.dest(destination));
}
function js() {
return Promise.all([
gulp.src(['./site/Scripts/**/*.js', '!./site/Scripts/**/serviceworker.js'])
.pipe(minifyJS())
.pipe(gulp.dest(destination + 'js/')),
gulp.src(['./site/Scripts/**/serviceworker.js'])
.pipe(minifyJS())
.pipe(gulp.dest(destination))
]);
}
function img() {
return gulp.src(destination + 'img/**')
.pipe(minifyIMG([
minifyIMG.gifsicle(),
minifyIMG.mozjpeg(),
minifyIMG.optipng(),
minifyIMG.svgo({plugins: [{removeViewBox: false}]})
]))
.pipe(gulp.dest(destination + 'img/'));
}
function netlify() {
return shell(`netlify deploy --dir=${destination} --prod`);
}
function browser() {
return shell('start firefox.exe -private-window https://jkc-codes.netlify.app');
}
exports.default = gulp.series(
reset,
gulp.parallel(
redirect,
css,
gulp.series(
eleventy,
gulp.parallel(
html,
js,
img
),
),
),
netlify,
gulp.parallel(
browser,
reset
)
);
exports.publish = gulp.series(
reset,
gulp.parallel(
css,
gulp.series(
eleventy,
gulp.parallel(
html,
js,
img
),
),
),
);