-
Notifications
You must be signed in to change notification settings - Fork 4
/
generator.js
48 lines (42 loc) · 1.09 KB
/
generator.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
'use strict';
// Require dependencies
var fs = require('fs');
var mkdirp = require('mkdirp');
var sass = require('node-sass');
var colors = require('colors');
// Config
var data = {
"input_name": __dirname + '/styles/scss/ocssipital.scss',
"output_dir": __dirname + '/styles/css/',
"output_name": __dirname + '/styles/css/ocssipital.css',
"nested": false
}
// Render Sass
function renderSass(){
// Output style
var outputStyle = 'compressed';
if (data.nested === true){
outputStyle = 'nested';
}
// Get CSS
sass.render({
file: data.input_name,
precision: 8,
outputStyle: outputStyle
}, function(err, css) {
if (err){
console.log('Error: could not compile: '.red + data.input_name.red);
console.log(err);
} else {
mkdirp(data.output_dir, function(err){
if (err) {
console.error(err);
} else {
fs.writeFileSync(data.output_name, css.css, 'utf8');
}
});
console.log('Success: '.green + data.input_name.green + ' was compiled to'.green + data.output_name.green);
}
});
}
renderSass();