-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathGulpfile.mjs
More file actions
74 lines (66 loc) · 1.82 KB
/
Gulpfile.mjs
File metadata and controls
74 lines (66 loc) · 1.82 KB
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
import gulp from "gulp";
import concat from "gulp-concat";
import htmlmin from "gulp-htmlmin";
import { nunjucksPrecompile } from "gulp-nunjucks";
import rename from "gulp-rename";
import uglify from "gulp-uglify";
gulp.task("scripts", () =>
gulp
.src([
"./video2commons/frontend/static/*.js",
"!./video2commons/frontend/static/*.min.js",
])
.pipe(rename({ suffix: ".min" }))
.pipe(uglify())
.pipe(gulp.dest("./video2commons/frontend/static/")),
);
gulp.task("jinja2", () =>
gulp
.src([
"./video2commons/frontend/templates/**.html",
"!./video2commons/frontend/templates/**.min.html",
])
.pipe(rename({ suffix: ".min" }))
.pipe(htmlmin({ collapseWhitespace: true, minifyCSS: true }))
.pipe(gulp.dest("./video2commons/frontend/templates/")),
);
gulp.task("nunjucks", () =>
gulp
.src(["./video2commons/frontend/static/templates/**.html"])
.pipe(htmlmin({ collapseWhitespace: true, minifyCSS: true }))
.pipe(nunjucksPrecompile())
.pipe(concat("../templates.min.js"))
.pipe(uglify())
.pipe(gulp.dest("./video2commons/frontend/static/templates")),
);
gulp.task("watch", () => {
var changeevent = (event) => {
console.log(`File ${event.path} was ${event.type}, running tasks...`);
};
gulp
.watch(
[
"./video2commons/frontend/static/*.js",
"!./video2commons/frontend/static/*.min.js",
],
gulp.series("scripts"),
)
.on("change", changeevent);
gulp
.watch(
[
"./video2commons/frontend/templates/**.html",
"!./video2commons/frontend/templates/**.min.html",
],
gulp.series("jinja2"),
)
.on("change", changeevent);
gulp
.watch(
["./video2commons/frontend/static/templates/**.html"],
gulp.series("nunjucks"),
)
.on("change", changeevent);
});
gulp.task("build", gulp.series("scripts", "jinja2", "nunjucks"));
gulp.task("default", gulp.series("build", "watch"));