Vue-cli upgrade to webpack4.6 error

webpack was also upgraded to version 4.6 during the vue-cli global upgrade package, and then the build project reported the following error,
webpack.optimize.CommonsChunkPlugin has been removed, please use config.optimization.splitChunks instead.

Baidu checked, and it is said that because webpack4.0 began to abandon CommonsChunkPlugin, it is necessary to change the new webpack.optimize.CommonsChunkPlugin in webpack.config.js to splitChunks.
because I have a vue-cli project, I can"t find the file webpack.config.js.

then I found new webpack.optimize.CommonsChunkPlugin in webpack.prod.conf.js and changed it to splitChunks. SplitChunks is not defined will be reported when build.

how should this situation be solved?

May.07,2021

the following is what I use to test webpack@4.x tests locally, I run oK, locally, and you'd better show the configuration and project structure of webpack, so as to help deal with problems more conveniently.

   
my local modification of the test function OK, does split the code

Menu