-
Notifications
You must be signed in to change notification settings - Fork 31
/
gulpfile.js
44 lines (41 loc) · 1.35 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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const { pathToFileURL } = require("url");
const autoprefixer = require("autoprefixer");
const cssnano = require("cssnano");
const litePreset = require("cssnano-preset-lite");
const postcss = require("gulp-postcss");
const rename = require("gulp-rename");
const gulpSass = require("gulp-sass");
const _sass = require("sass");
/* eslint-enable @typescript-eslint/no-var-requires */
const sass = gulpSass(_sass);
const scssFiles = ["**/*.scss", "!example/*.scss", "!documentation/*.scss"];
function throwSassError(e) {
sass.logError(e);
throw new Error("sass compilation failed");
}
module.exports = function (gulp) {
gulp.task("build", function () {
return gulp
.src(scssFiles)
.pipe(
sass({
loadPaths: ["./node_modules"],
}).on("error", throwSassError),
)
.pipe(postcss([autoprefixer()]))
.pipe(gulp.dest("./"))
.pipe(postcss([cssnano(litePreset())]))
.pipe(rename({ suffix: ".min" }))
.pipe(gulp.dest("./"));
});
gulp.task("build:watch", function () {
return gulp.watch(
scssFiles,
{ ignoreInitial: false },
gulp.series("build"),
);
});
return gulp;
};