-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-css.js
40 lines (36 loc) · 1007 Bytes
/
build-css.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
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
const postcss = require('postcss');
const autoprefixer = require('autoprefixer');
const csso = require('postcss-csso');
if (!fs.existsSync('dist')) {
fs.mkdirSync('dist');
}
const input = path.join(__dirname, 'src', 'custom-scroll.css');
const output = path.join(__dirname, 'dist', 'custom-scroll.css');
const outputMin = path.join(__dirname, 'dist', 'custom-scroll.min.css');
const buildCSS = (css, plugins, options) => {
return postcss(plugins)
.process(css, options)
.then(result => promisify(fs.writeFile)(options.to, result.css))
}
promisify(fs.readFile)(input)
.then(css => {
return Promise.all([
buildCSS(css, [autoprefixer], {
from: input,
to: output
}),
buildCSS(css, [
autoprefixer,
csso({
restructure: false
})
], {
from: input,
to: outputMin
}),
])
})
.catch(console.error);