-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
31 lines (27 loc) · 1.01 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
const minimist = require("minimist");
const through = require("through2");
const stylus = require("stylus");
const gulp = require("gulp");
const path = require("path");
gulp.task("default", () => {
const { s, m } = minimist(process.argv.slice(2));
const schemePath = path.join(__dirname, "./src/schemes", s) + ".styl";
// Compiles all SASS files to CSS
return gulp
.src(`./src/modules/${m || "*"}.styl`)
.pipe(styl(schemePath))
.pipe(gulp.dest(`./use/${s}`, { overwrite: true }));
});
function styl(schemePath) {
return through.obj((file, encoding, callback) => {
stylus(file.contents.toString(), { filename: file.path, compress: true })
.import(schemePath)
.set("include css", true)
.render((err, css) => {
if (err) callback(err.toString());
file.path = file.path.replace(/[.]styl$/, ".css");
file.contents = Buffer.from(css);
callback(null, file);
});
});
}