-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcompile_addons.js
33 lines (31 loc) · 973 Bytes
/
compile_addons.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
const fs = require('node:fs');
const sass = require('node-sass');
const util = require('util');
const path = require('path');
const addons = './src/addons';
const outputPath = './public'
const data = `\
$version: 'x';
@import 'lib/selectors/selectorPlaceholders';
@import 'src/functions';
@import 'src/variables';
@import 'src/mixins';
@import 'src/addons/%s';`;
fs.mkdirSync(outputPath);
fs.readdirSync(addons).forEach(file => {
const name = path.parse(file).name;
sass.render({
data: util.format(data, name),
outputStyle : 'expanded',
sourceMap: false,
}, function(err, result) {
if(err) console.log(err);
if(result) {
const output = result.css.toString().replace(/\*\/\n/g, '*/\n\n');
fs.writeFile(`${outputPath}/${name}.css`, output, err => {
if(err) console.log(err);
else console.log(`Successfully wrote ${name}.css`);
});
}
});
});