-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgulpfile.cjs
59 lines (51 loc) · 1.45 KB
/
gulpfile.cjs
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
const { src, dest, watch, series, parallel } = require("gulp");
const sass = require("gulp-sass")(require("sass"));
const concat = require("gulp-concat");
const terser = require("gulp-terser");
const postcss = require("gulp-postcss");
const rename = require("gulp-rename");
const autoprefixer = require("autoprefixer");
const cssnano = require("cssnano");
const files = {
scssPath: "fediverse-share-button/src/styles/*.scss",
jsPath: "fediverse-share-button/src/scripts/**/*.js",
};
function scssTask() {
return src(files.scssPath)
.pipe(sass())
.pipe(postcss([autoprefixer(), cssnano()]))
.pipe(
rename({
suffix: ".min",
})
)
.pipe(dest("fediverse-share-button"));
}
function jsTask() {
return (
src(
[
"fediverse-share-button/src/scripts/modules/*.js",
"fediverse-share-button/src/scripts/main.js"
]
)
.pipe(terser())
.pipe(concat("script.js"))
.pipe(rename({
suffix: '.min'
}))
.pipe(dest("fediverse-share-button"))
);
}
function watchJS() {
watch([files.jsPath], { interval: 1000, usePolling: true }, series(jsTask));
}
function watchCSS() {
watch(
[files.scssPath],
{ interval: 1000, usePolling: true },
series(scssTask)
);
}
exports.default = series(parallel(scssTask, jsTask));
exports.watch = series(parallel(scssTask, jsTask), parallel(watchJS, watchCSS));