Created
July 15, 2021 05:30
-
-
Save i-rocky/1ddd7c10604adbf6db6c4fc668b76214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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