-
Notifications
You must be signed in to change notification settings - Fork 25
/
gulpfile.js
47 lines (41 loc) · 1.2 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
/* eslint-disable no-console */
const gulp = require("gulp");
const htmlmin = require("gulp-htmlmin");
const cleanCSS = require("gulp-clean-css");
const inlinesource = require("gulp-inline-source");
const path = require("path");
const del = require("del");
const html = () =>
gulp
.src("src/*.html")
.pipe(inlinesource({ rootpath: path.resolve("dist") }))
.pipe(
htmlmin({
collapseWhitespace: true,
// removeOptionalTags: true,
collapseBooleanAttributes: true,
})
)
.pipe(gulp.dest("dist"));
const css = () =>
gulp
.src("src/styles/*.css")
.pipe(
cleanCSS({ debug: true, level: 2 }, (details) => {
console.log(`${details.name}: ${details.stats.originalSize}`);
console.log(`${details.name}: ${details.stats.minifiedSize}`);
})
)
.pipe(gulp.dest("dist/styles"));
const purge = () => del(["dist/styles"]);
const assets = () => gulp.src("public/*").pipe(gulp.dest("dist"));
const dev = () =>
gulp.watch(
["src/**/*"],
{ ignoreInitial: false },
gulp.series(css, html, purge, assets)
);
exports.html = html;
exports.css = css;
exports.dev = dev;
exports.default = gulp.series(css, html, purge, assets);