forked from zencoder/html5-boilerplate-for-wordpress
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
100 lines (84 loc) · 1.9 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
// REQUIRES
const { watch, series, parallel, src, dest } = require("gulp");
const livereload = require('gulp-livereload');
const sourcemaps = require("gulp-sourcemaps");
const sass = require("gulp-sass")(require('sass'));
const consolidate = require("gulp-consolidate");
const rename = require("gulp-rename");
const iconfont = require("gulp-iconfont");
//
// VARS
//
const paths = {
php: "**/**/*.php",
scss: "scss/**/**/*.scss",
scssBase: "scss/base.scss",
scssDest: "scss",
icons: "scss/icons",
};
const sassOptions = {
outputStyle: "compressed",
};
//
// GENERATORS
//
function generateSass(done) {
return src(paths.scssBase)
.pipe(sourcemaps.init())
.pipe(sass(sassOptions).on("error", sass.logError))
.pipe(sourcemaps.write("./"))
.pipe(dest(paths.scssDest))
.pipe(livereload());
}
function generateIcons() {
return src(paths.icons + "/src/*.svg")
.pipe(
iconfont({
fontName: "icons",
formats: ["ttf", "eot", "woff", "woff2"],
prependUnicode: false,
normalize: true,
fontHeight: 1001,
centerHorizontally: true,
})
)
.on("glyphs", function (glyphs, options) {
src(paths.icons + "/src/template.css")
.pipe(
consolidate("underscore", {
glyphs: glyphs,
fontName: options.fontName,
fontDate: new Date().getTime(),
})
)
.pipe(rename("icons.css"))
.pipe(dest(paths.icons));
})
.pipe(dest(paths.icons));
}
// FUNCTIONS
function generateFiles(done) {
return series(generateSass, generateIcons)(done);
}
function watchFiles() {
livereload.listen();
// Watch SCSS
watch(paths.scss).on(
"change",
series(generateSass, (done) => {
done();
})
);
// Watch Icons
watch(paths.icons + "/src/*.svg").on(
"change",
series(generateIcons, generateSass, (done) => {
done();
})
);
// Watch PHP
watch(paths.php).on("change", () => {
livereload.reload();
});
}
exports.default = series(generateFiles, watchFiles);