-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsass-build.js
38 lines (31 loc) · 1.11 KB
/
sass-build.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
const fs = require('fs')
const path = require('path')
const sass = require('node-sass')
// Validate command line arguments.
if (process.argv.length < 3) {
console.log('Please provide either "dark" or "light" as the first argument.')
process.exit(1)
}
// Dark or light?
const styleType = process.argv[2] === 'dark' ? 'dark' : 'light'
// Minify?
const styleMin = process.argv[3] && process.argv[3] !== '' ? process.argv[3] : null
const sassPath = path.join(__dirname, 'sass')
const saveFile = path.join(__dirname, 'dist', `bulwark-${styleType}.css`)
const saveFileMin = path.join(__dirname, 'dist', `bulwark-${styleType}.min.css`)
sass.render({
file: path.join(sassPath, `bulwark-${styleType}.scss`),
// includePaths: [path.join(sassPath, 'include')],
outFile: styleMin ? saveFileMin : saveFile,
outputStyle: styleMin ? 'compressed' : 'nested'
}, (err, result) => {
if (err) {
return console.error(err)
}
fs.writeFile(styleMin ? saveFileMin : saveFile, result.css, (err) => {
if (err) {
return console.error(err)
}
console.log(`${styleMin ? saveFileMin : saveFile} saved to system!`)
})
})