Last active
May 6, 2022 17:06
-
-
Save dekadentno/64d808856d5993a8751c3a4b8088ad4b to your computer and use it in GitHub Desktop.
Vue CLI 3 + PurgeCSS
This file contains 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
/** | |
1) npm i -D purgecss @fullhuman/postcss-purgecss purgecss-webpack-plugin glob-all path | |
2) edit vue.config.js | |
*/ | |
/** | |
** vue.config.js | |
*/ | |
const PurgecssPlugin = require('purgecss-webpack-plugin'); | |
const glob = require('glob-all'); | |
const path = require('path'); | |
module.exports = { | |
configureWebpack() { | |
// Additional config to be merged | |
let additionalConfig = {}; | |
// Production config | |
if (process.env.NODE_ENV === 'production') { | |
additionalConfig = { | |
plugins: [ | |
new PurgecssPlugin({ | |
paths: glob.sync([ | |
path.join(__dirname, './public/index.html'), | |
path.join(__dirname, './src/**/*.vue'), | |
path.join(__dirname, './src/**/*.html'), | |
]), | |
}), | |
], | |
}; | |
} | |
return additionalConfig; | |
}, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment