Skip to content

Instantly share code, notes, and snippets.

@oleersoy
Last active January 15, 2019 18:24
Show Gist options
  • Select an option

  • Save oleersoy/81afac18b450ef45eb7ede6ddbeac978 to your computer and use it in GitHub Desktop.

Select an option

Save oleersoy/81afac18b450ef45eb7ede6ddbeac978 to your computer and use it in GitHub Desktop.
postcss uncss
const postcss = require('postcss')
const fs = require('fs')
const options = {
html: ['html/*.html']
}
fs.readFile('css/index.css','utf8', (err, css) => {
postcss([require('postcss-uncss')(options)])
.process(css, { from: 'css/app.css', to: 'css/filtered.css' })
.then(result => {
fs.writeFile('css/filtered.css', result.css, () => true)
if ( result.map ) {
fs.writeFile('dest/app.css.map', result.map, () => true)
}
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment