can i modify vendors.js file name with webpack?

Viewed 22

I have to modify filenames when build vuejs project with webpack.

I'm using webpack 4.x.x vuejs 2.x.x version.

And have to modify file name of "vendors.js" and "runtime.js" to "vendors.pc.js" and "runtime.pc.js"

Can I change them when build it?

1 Answers

add this to your webpack.config.js, then webpack will map node_modules files into different chunk files according to your cacheGroups settings

optimization: {
  runtimeChunk: 'single',
  splitChunks: {
    chunks: 'all',
    maxInitialRequests: Infinity,
    minSize: 0,
    cacheGroups: {
      reactVendor: {
        test: /[\\/]node_modules[\\/](react|react-dom)[\\/]/,
        name: "reactvendor"
      },
      utilityVendor: {
        test: /[\\/]node_modules[\\/](lodash|moment|moment-timezone)[\\/]/,
        name: "utilityVendor"
      },
      bootstrapVendor: {
        test: /[\\/]node_modules[\\/](react-bootstrap)[\\/]/,
        name: "bootstrapVendor"
      },
      vendor: {
        test: /[\\/]node_modules[\\/](!react-bootstrap)(!lodash)(!moment)(!moment-timezone)[\\/]/,
        name: "vendor"
      },
    },
  },
}
Related