forked from huyb1991/hugo-lamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
33 lines (31 loc) · 902 Bytes
/
index.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
/**
* Copy right: https://gohugo-amp.gohugohq.com/styling/
*/
const sass = require('node-sass'),
postcss = require('postcss'),
fs = require('fs'),
inputFile = './styles/main.scss',
outputFile = './layouts/partials/stylesheet.html'
sass.render({
file: inputFile,
outputStyle: 'compressed'
}, (error, result) => {
if (error) {
console.log(error.status);
console.log(error.column);
console.log(error.message);
console.log(error.line);
} else {
let cssOutput = result.css.toString();
postcss([ require('autoprefixer'), require('cssnano') ])
.process(cssOutput)
.then((result) => {
fs.writeFile(outputFile, result.css, err => {
if (err) {
return console.log(err);
}
console.log('\u2611 file '+outputFile+' updated with current styling from '+ inputFile);
});
});
}
});