forgeplus-react/scripts/purge-css.js

21 lines
620 B
JavaScript
Raw Normal View History

2020-04-28 17:23:34 +08:00
const { PurgeCSS } = require('purgecss')
var fs = require('fs');
async function purgeBuild() {
const purgeCSSResult = await new PurgeCSS().purge({
content: ['../src/**/*.js', '../src/**/*.jsx',],
css: ['../public/css/edu-public.css', '../public/css/taskstyle.css', '../public/css/edu-main.css', '../public/css/edu-all.css']
})
let result = []
for (let i = 0; i < purgeCSSResult.length; i++) {
let item = purgeCSSResult[i]
result.push(item.css)
}
fs.writeFile('../public/css/edu-purge.css', result.join(''), 'utf8', function (err) {
if (err) return console.log(err)
})
}
purgeBuild()