When working on a project, I found it helpful to customize the settings in vue.config.js
for packaging a web component and extracting a separate section of iconfont.css. By utilizing the configureWebpack option, you can easily achieve this functionality. Take a look at the code snippet below for an example:
// vue.config.js
module.exports = {
configureWebpack: (config) => {
// Additional webpack configuration
if (process.env.NODE_ENV === 'production') {
// Customize production build
// Separate section of iconfont.css extraction
config.optimization.splitChunks.cacheGroups.styles = {
name: 'iconfont',
test: /[\\/]node_modules[\\/].*iconfont\.css$/,
chunks: 'all',
enforce: true,
};
}
},
};