forked from s-yadav/iv-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-css.js
24 lines (19 loc) · 917 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
const fs = require('fs');
const util = require('util');
const sass = require('sass');
const autoprefixer = require('autoprefixer');
const cssnano = require('cssnano');
const postcss = require('postcss');
const writeFile = util.promisify(fs.writeFile);
// build css
const filePath = './src/ImageViewer.scss';
const css = sass.renderSync({ file: filePath }).css.toString();
async function compileCss () {
const unminifiedCssPromise = postcss([autoprefixer]).process(css, { from: undefined });
const minifiedCssPromise = postcss([cssnano, autoprefixer]).process(css, { from: undefined });
const [unminifiedCss, minifiedCss] = await Promise.all([unminifiedCssPromise, minifiedCssPromise]);
const distUnminified = writeFile('./dist/iv-viewer.css', unminifiedCss);
const distMinified = writeFile('./dist/iv-viewer.min.css', minifiedCss);
return Promise.all([distUnminified, distMinified]);
}
compileCss();