-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.js
More file actions
31 lines (29 loc) · 833 Bytes
/
build.js
File metadata and controls
31 lines (29 loc) · 833 Bytes
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 fs = require('fs-extra');
const sass = require('node-sass');
const tildeImporter = require('node-sass-package-importer');
const chalk = require('chalk');
const postcss = require('postcss');
const postcssrc = require('postcss-load-config');
const srcPath = './src/index.scss';
const outPath = './dist/index.css';
sass.render({
file: srcPath,
outputStyle: 'compressed',
importer: tildeImporter(),
}, function(err, result) {
if (err) {
console.log(chalk.red('error!', err));
} else {
postcssrc().then(({ plugins, options }) => {
postcss(plugins)
.process(result.css, options)
.then((result) => {
fs.outputFile(outPath, result, function(err) {
if (!err) {
console.log(chalk.green(`success! created ${outPath}`));
}
});
});
});
}
});