-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (61 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
"use strict";
const path = require("path");
const gulp = require("gulp");
const autoprefixer = require("gulp-autoprefixer");
const sass = require("gulp-sass")(require("sass"));
const purgecss = require("gulp-purgecss");
const cleanCSS = require("gulp-clean-css");
const concat = require("gulp-concat");
const terser = require("gulp-terser");
const CAP_ROOT = path.join(__dirname, "..", "CAP", "root");
const CAP_STATIC = path.join(CAP_ROOT, "static");
const TEMPLATES = ["*.tt", "*.html"].map((glob) =>
path.posix.join(CAP_ROOT, "templates", "**", glob)
);
const css = (watch = false) =>
function css() {
let stream = gulp.src("./scss/portals/*.scss").pipe(
sass({
includePaths: ["./node_modules/bootstrap/scss"],
}).on("error", sass.logError)
);
if (!watch) {
stream = stream
.pipe(
purgecss({
content: TEMPLATES,
safelist: { deep: [/tooltip/, /collapsing/] },
})
)
.pipe(cleanCSS())
.pipe(autoprefixer());
}
return stream.pipe(gulp.dest(path.join(CAP_STATIC, "css")));
};
const js = (watch = false) =>
function js() {
let stream = gulp
.src(
[
"./js/early/*.js",
"./node_modules/jquery/dist/jquery.js",
"./node_modules/popper.js/dist/umd/popper.js",
"./node_modules/bootstrap/dist/js/bootstrap.js",
"./node_modules/openseadragon/build/openseadragon/openseadragon.js",
"./js/*.js",
],
{ sourcemaps: true }
)
.pipe(concat("cap.js"));
if (!watch) stream = stream.pipe(terser());
return stream.pipe(gulp.dest(path.join(CAP_STATIC, "js")));
};
exports.default = gulp.parallel(css(false), js(false));
exports.watch = () => {
gulp.watch(
["./scss/**/*.scss", ...TEMPLATES],
{ ignoreInitial: false },
css(true)
);
gulp.watch("./js/**/*.js", { ignoreInitial: false }, js(true));
};