-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
63 lines (53 loc) · 1.28 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
'use-strict';
const {
src, dest, watch, series,
} = require('gulp');
const minifyCSS = require('gulp-csso');
const htmlmin = require('gulp-htmlmin');
const size = require('gulp-size');
const del = require('del');
const fs = require('fs');
const sizeFactory = (title) => size({
title,
showFiles: true,
});
const html = () => {
return src('app/*.html')
.pipe(htmlmin({ collapseWhitespace: true }))
.pipe(sizeFactory('html'))
.pipe(dest('dist/'));
};
const static = () => {
return src('app/static/**')
.pipe(sizeFactory('static'))
.pipe(dest('dist/static'));
};
const assets = () => {
return src('app/assets/**')
.pipe(sizeFactory('assets'))
.pipe(dest('dist/assets'));
};
const copy = () => {
return src(['app/manifest.json', 'app/favicon.ico'])
.pipe(dest('dist/'));
};
const css = () => {
return src('app/css/*.css')
.pipe(minifyCSS())
.pipe(sizeFactory('css'))
.pipe(dest('dist/css'));
};
const watcher = () => {
return watch('/app', series(clean, html, css, assets, static, copy));
};
const clean = (cb) => {
if (fs.existsSync('/dist')) {
del.sync('/dist');
}
cb();
};;
exports.css = css;
exports.html = html;
exports.watcher = watcher;
exports.clean = clean;
exports.default = series(clean, html, css, assets, static, copy);