forgeplus-react/scripts/purge-css.js

21 lines
620 B
JavaScript

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()