Created
January 12, 2017 20:47
-
-
Save ezekielchentnik/1146f8269257f075fd8dce42dbb630c9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const fs = require('fs') | |
const _sass = require('node-sass') | |
const cssnano = require('cssnano') | |
const purifycss = require('purify-css') | |
const promisify = (ctx, func = ctx) => (...args) => { | |
return new Promise((resolve, reject) => { | |
func.apply(ctx, [...args, (err, result) => err ? reject(err) : resolve(result)]) | |
}) | |
} | |
const writeFile = promisify(fs.writeFile) | |
const sass = promisify(_sass.render) | |
const css = () => sass({ file: `src/app/styles/entry.scss` }) | |
.then(({ css }) => purifycss(['src/app/components/**/*.js'], css.toString())) | |
.then((purified) => cssnano.process(purified, { autoprefixer: { add: true } })) | |
.then(({ css }) => writeFile(`build/public/bundle.css`, css)) | |
css() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment