[Vuejs]-Web component packaging Settings

0👍

With me, I set the specific settings in vue.config.js for packaging a web component and extracting a separate section of iconfont.css, you can make use of the configureWebpack option. Here’s an example of how you can achieve that:

// vue.config.js
module.exports = {
configureWebpack: (config) => {

// Add additional webpack configuration
if (process.env.NODE_ENV === 'production') {

// Configuration for production build
// Extract a separate section of iconfont.css
  config.optimization.splitChunks.cacheGroups.styles = {
    name: 'iconfont',
    test: /[\\/]node_modules[\\/].*iconfont\.css$/,
    chunks: 'all',
    enforce: true,
  };
}
},
};

Leave a comment