-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathgulpfile.js
74 lines (66 loc) · 1.83 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
"use strict";
var gulp = require("gulp");
var browserSync = require("browser-sync").create();
var htmlMin = require("gulp-htmlmin");
var sass = require("gulp-sass");
var cleanCss = require("gulp-clean-css");
var inlineCss = require("gulp-inline-css");
var panini = require("panini");
var inky = require("inky");
/* Compile SASS into Minify CSS */
gulp.task("sass", function() {
return gulp
.src("src/scss/*.scss")
.pipe(sass())
.pipe(cleanCss())
.pipe(gulp.dest("dist/css"));
});
/* Integrate All Layout from Panini */
gulp.task("panini", function() {
return gulp
.src("src/pages/**/*.html")
.pipe(
panini({
root: "src/pages/",
layouts: "src/layouts/",
partials: "src/partials/",
data: "src/data/"
})
)
.pipe(inky())
.pipe(gulp.dest("dist/"));
});
/* Make HTML Clean and Minify, also Make CSS Inline on Tag */
gulp.task("htmlMin", function() {
return gulp
.src("dist/**/*.html")
.pipe(
htmlMin({
collapseWhitespace: true,
removeComments: true
})
)
.pipe(inlineCss({
removeHtmlSelectors: true
}))
.pipe(gulp.dest("dist/"));
});
/* Static Server */
gulp.task("browserSync", function() {
browserSync.init({
server: {
baseDir: "./dist/"
}
});
});
/* Watch all Changes */
gulp.task("watch", function() {
gulp.watch("src/scss/*.scss", gulp.parallel("sass"));
gulp.watch("src/pages/**/*.html", gulp.parallel("panini"));
gulp.watch("src/pages/**/*.html").on("change", browserSync.reload);
gulp.watch("src/scss/*.scss").on("change", browserSync.reload);
});
/* Build emails, run the server, and watch for file changes */
gulp.task("default", gulp.parallel("sass", "panini", "watch", "browserSync"));
/* Build the "dist" folder by running all of the below tasks */
gulp.task("build", gulp.parallel("htmlMin"));