forked from fancyapps/ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-css.js
43 lines (37 loc) · 1.04 KB
/
build-css.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
const fs = require("fs");
const sass = require("sass");
const files = ["Panzoom", "Panzoom.Controls", "Carousel", "Fancybox"];
for (const file_name of files) {
let input_file;
let output_file;
const words = file_name.split(".");
const component = words[0];
const plugin = words[1] || false;
if (plugin) {
input_file = `./src/${component}/plugins/${plugin}/${plugin}.scss`;
output_file = `./dist/${component.toLowerCase()}.${plugin.toLowerCase()}.css`;
} else {
input_file = `./src/${component}/${component}.scss`;
output_file = `./dist/${component.toLowerCase()}.css`;
}
console.log(`${input_file} → ${output_file}...`);
sass.render(
{
file: input_file,
outputStyle: "compressed",
},
(error, result) => {
if (!error) {
fs.writeFile(output_file, result.css, (err) => {
if (!err) {
console.log(`Created ${output_file}`);
} else {
console.error(err);
}
});
} else {
console.error(error);
}
}
);
}