Skip to content

Instantly share code, notes, and snippets.

@dekadentno
Last active May 6, 2022 17:06
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dekadentno/64d808856d5993a8751c3a4b8088ad4b to your computer and use it in GitHub Desktop.
Save dekadentno/64d808856d5993a8751c3a4b8088ad4b to your computer and use it in GitHub Desktop.
Vue CLI 3 + PurgeCSS
/**
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