-
Notifications
You must be signed in to change notification settings - Fork 6
/
gulpfile.js
58 lines (47 loc) · 1.47 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
"use strict";
const gulp = require("gulp");
const sass = require("gulp-sass");
const sourcemaps = require("gulp-sourcemaps");
const concat = require("gulp-concat");
const cssnano = require("cssnano");
const postcss = require("gulp-postcss");
const { spawn } = require("child_process");
sass.compiler = require("sass");
const sassDev = function () {
return gulp
.src("./src/styles/**/*.scss")
.pipe(sourcemaps.init())
.pipe(sass().on("error", sass.logError))
.pipe(concat("index.css"))
.pipe(sourcemaps.write())
.pipe(gulp.dest("./resources/public/css"));
};
exports.watchSass = function () {
gulp.watch("./src/styles/**/*.scss", { ignoreInitial: false }, sassDev);
};
exports.buildSassProd = function () {
var plugins = [cssnano()];
return gulp
.src("./src/styles/**/*.scss")
.pipe(sass().on("error", sass.logError))
.pipe(concat("index.css"))
.pipe(postcss(plugins))
.pipe(gulp.dest("./resources/public/css"));
};
exports.runShadow = function (cb) {
const shadow = spawn("yarn", ["run", "shadow-cljs", "watch", "app"]);
shadow.stdout.on("data", (data) => {
process.stdout.write(`shadow-cljs: ${data}`);
});
shadow.stderr.on("data", (data) => {
process.stderr.write(`shadow-cljs: ${data}`);
});
shadow.on("close", (code) => {
if (code === 0) {
cb();
} else {
cb(new Error(`shadow-cljs exited with return code ${code}`));
}
});
};
exports.default = gulp.parallel(exports.watchSass, exports.runShadow);