Skip to content

Instantly share code, notes, and snippets.

@ezekielchentnik
Created January 12, 2017 20:47
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save ezekielchentnik/1146f8269257f075fd8dce42dbb630c9 to your computer and use it in GitHub Desktop.
Save ezekielchentnik/1146f8269257f075fd8dce42dbb630c9 to your computer and use it in GitHub Desktop.
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