-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
50 lines (46 loc) · 1.13 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
const fs = require("fs"),
gulp = require("gulp"),
pug = require("gulp-pug"),
scss = require("gulp-sass")(require("sass")),
autoprefixer = require("gulp-autoprefixer"),
babel = require("gulp-babel"),
uglify = require("gulp-uglify");
// HTML Tasks
gulp.task("html", () =>
gulp
.src("src/pug/pages/*.pug")
.pipe(
pug({
locals: {
tabsData: JSON.parse(fs.readFileSync("src/data.json", "utf8")),
},
})
)
.pipe(gulp.dest("dist"))
);
// CSS Tasks
gulp.task("css", () =>
gulp
.src("src/scss/pages/*.scss")
.pipe(scss({ outputStyle: "compressed" }))
.pipe(autoprefixer("last 2 versions"))
.pipe(gulp.dest("dist/assets/styles"))
);
// JS Tasks
gulp.task("js", () =>
gulp
.src("src/js/*.js")
.pipe(
babel({
plugins: ["@babel/transform-runtime"],
})
)
.pipe(uglify())
.pipe(gulp.dest("src/js/dist"))
);
// Watch All Tasks
gulp.task("default", () => {
gulp.watch("src/pug/**/*.pug", gulp.series("html"));
gulp.watch("src/scss/**/*.scss", gulp.series("css"));
gulp.watch("src/js/*.js", gulp.series("js", gulp.series("html")));
});