-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild-sass.js
More file actions
52 lines (47 loc) · 1.27 KB
/
build-sass.js
File metadata and controls
52 lines (47 loc) · 1.27 KB
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
49
50
51
52
const sass = require('node-sass')
const path = require('path')
const {mkdirAsync, writeFileAsync} = require('./file')
let distCssDir = path.resolve(__dirname, '../dist/')
let includePaths = [
path.resolve(__dirname, '../scss')
]
// nested, expanded, compact, compressed
let outputStyle = 'expanded'
mkdirAsync(distCssDir).then(() => {
return Promise.all([
sassRenderAsync({
outputStyle,
sourceMap: true,
file: path.resolve(__dirname, '../scss/vui.scss'),
outFile: path.resolve(distCssDir, 'vui.css'),
includePaths
}),
sassRenderAsync({
outputStyle,
sourceMap: true,
file: path.resolve(__dirname, '../scss/generics.scss'),
outFile: path.resolve(distCssDir, 'generics.css'),
includePaths
}),
]).then(() => {
console.log('Done')
})
}).catch((err) => {
console.error(err)
process.exit(1)
})
function sassRenderAsync (opts) {
return new Promise((resolve, reject) => {
sass.render(opts, (err, result) => {
if (err) {
return reject(err)
}
let {outFile, sourceMap} = opts
let ret = [writeFileAsync(outFile, result.css)]
if (sourceMap) {
ret.push(writeFileAsync(outFile + '.map', result.map))
}
Promise.all(ret).then(resolve, reject)
})
})
}