-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
65 lines (56 loc) · 1.7 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
import * as rollup from "rollup";
import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import postcss from "rollup-plugin-postcss";
import {terser} from "rollup-plugin-terser";
import gulp from 'gulp';
import squoosh from 'gulp-libsquoosh';
import htmlmin from 'gulp-html-minifier-terser';
import {runZola} from "./bin/zola.js";
const prepackage = () => {
return rollup.rollup({
input: ['src/main.js'],
plugins: [
resolve(),
commonjs(),
postcss({
use: ['sass'],
extract: true,
minimize: true
}),
terser()
]
}).then(bundle => {
return bundle.write({
file: 'static/bundle.js',
format: 'iife',
sourcemap: true,
});
});
};
const zolaBuild = async () => {
runZola(['build']);
};
export const postProcessHtml = () => {
return gulp.src('public/**/*.html')
.pipe(htmlmin({
collapseWhitespace: true,
collapseBooleanAttributes: true,
minifyCss: true,
minifyJs: true,
removeComments: true,
sortAttributes: true,
sortClassName: true
}))
.pipe(gulp.dest('public/'))
}
export const postProcessImages = () => {
return gulp.src(['public/posts/**/*.png', 'public/posts/**/*.jpg', 'public/posts/**/*.gif'])
// .on("data", console.log)
.pipe(squoosh())
.pipe(gulp.dest('public/posts/'))
}
export const watch = async () => {
gulp.watch(['src/**/*'], gulp.series(prepackage));
}
export default gulp.series(prepackage, zolaBuild, postProcessHtml, postProcessImages);