Skip to content

Instantly share code, notes, and snippets.

@i-rocky
Created July 15, 2021 05:30
Show Gist options
  • Select an option

  • Save i-rocky/1ddd7c10604adbf6db6c4fc668b76214 to your computer and use it in GitHub Desktop.

Select an option

Save i-rocky/1ddd7c10604adbf6db6c4fc668b76214 to your computer and use it in GitHub Desktop.
const {PurgeCSS} = require('purgecss');
const minify = require('minify');
const scope = require('scope-css');
const fs = require('fs');
const path = require('path');
(new PurgeCSS()).purge({
content: [
'app/design/frontend/Magento/ady/**/*.phtml',
'app/design/frontend/Magento/ady/**/*.html',
'app/code/Ady/**/*.php'],
css: ['app/design/frontend/Magento/ady/**/*.css'],
}).then(results => {
results.forEach(async result => {
if (result.file.includes('-purged.css')) {
return true;
}
const filename = path.resolve(__dirname, result.file + '-purged.css');
fs.writeFileSync(filename, result.css);
fs.writeFileSync(filename, scope(await minify(filename), '.ady'));
});
console.log('Done');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment