如何使用Webpack将node_modules中的模块捆绑为服务器捆绑

时间:2020-03-01 09:44:59

标签: vue.js webpack bundle webpack-4 webpack-splitchunks

我正在尝试在Webpack4中使用splitChunks,希望将node_modules中的模块捆绑成几个捆绑,但是我的代码无法正常工作

optimization:{
splitChunks:{
  cacheGroups:{
    vendors:{
      test:/[\\\/]node_modules[\\\/]vue[\\\/]/,
      name:'js/chunk-vendors',
      chunks:'initial',
    },
    ui:{
      test:/[\\\/]node_modules[\\\/]element-ui[\\\/]/,
      name:'js/chunk-element',
      chunks:'initial',
    },
    basic:{
      test:/[\\\/]node_modules[\\\/](vue-router|vuex)[\\\/]/,
      name:'js/chunk-basic',
      chunks:'initial',
    },
    common:{
      test:/[\\\/]src[\\\/]/,
      name:'js/chunk-common',
      minChunks:2,
      chunks:'initial',
    }
  }
}

},

仅生成chunk-basic.jschunk-element.js; 我希望将其作为配置输出,该怎么办?

0 个答案:

没有答案