forked from bennettfeely/bennett
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
121 lines (111 loc) · 2.55 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
gulp = require("gulp");
jade = require("gulp-jade");
slim = require("gulp-slim");
htmlmin = require("gulp-htmlmin");
sass = require("gulp-sass");
autoprefixer = require("gulp-autoprefixer");
cssnano = require("gulp-cssnano");
browserSync = require("browser-sync");
rename = require("gulp-rename");
jsImport = require("gulp-js-import");
uglify = require("gulp-uglify");
concat = require("gulp-concat");
pump = require("pump");
path = require("path");
fs = require("fs");
del = require("del");
// Compile Jade to HTML ==================================================================
gulp.task("slim", function () {
return gulp
.src("_src/*.slim")
.pipe(
slim({
pretty: true,
})
)
.pipe(
htmlmin({
collapseWhitespace: true,
removeComments: true,
minifyCSS: true,
minifyJS: true,
})
)
.pipe(gulp.dest(""))
.pipe(
browserSync.reload({
stream: true,
})
);
});
gulp.task("jade", function () {
return gulp
.src("_src/index.jade")
.pipe(
jade({
pretty: true,
})
)
.pipe(
htmlmin({
collapseWhitespace: true,
removeComments: true,
minifyCSS: true,
minifyJS: true,
})
)
.pipe(gulp.dest("./"))
.pipe(
browserSync.reload({
stream: true,
})
);
});
// Compile CSS ===========================================================================
gulp.task("scss", function () {
return gulp
.src("_src/scss/*.scss")
.pipe(sass())
.on("error", sass.logError)
.pipe(
autoprefixer({
browsers: ["last 2 versions"],
cascade: false,
})
)
.pipe(cssnano())
.pipe(
rename(function (path) {
path.basename += ".min";
path.extname = ".css";
})
)
.pipe(gulp.dest("./"))
.pipe(
browserSync.reload({
stream: true,
})
);
});
// Browser sync ==========================================================================
gulp.task("sync", function () {
return browserSync({
server: "",
});
});
// Init ==================================================================================
gulp.task("default", function () {
gulp.run("sync");
gulp.watch(["_src/*.jade"], function () {
return gulp.run("jade");
});
gulp.watch(["_src/*.slim"], function () {
return gulp.run("slim");
});
gulp.watch(["_src/articles/*/*.jade"], function () {
return gulp.run("jade-article");
});
gulp.watch("_src/scss/*.scss", function () {
return gulp.run("scss");
});
});