code_shuai
code_shuai

Reputation: 1

the function setWebpackOptimizationSplitChunks in customize-cra does not work properly?

The application I created using create-react-app uses customize-cra and react-app-rewired to override some configurations of webpack. When I use the setWebpackOptimizationSplitChunks function and run pnpm start, the project cannot run correctly and stays at Starting. the development server... , what is the problem? Or are there other solutions that cover webpack? Because I don't want to run eject.

code

const {
  override,
  disableEsLint,
  overrideDevServer,
  watchAll,
  setWebpackOptimizationSplitChunks,
} = require("customize-cra");

module.exports = {
  webpack: override(
    // usual webpack plugin
    disableEsLint(),
    setWebpackOptimizationSplitChunks({
      chunks: 'all',
      name: false,
    }),
  ),
  devServer: overrideDevServer(
    // dev server plugin
    watchAll()
  )
};

After adding setWebpackOptimizationSplitChunks function, run pnpm start the command line will be stuck at

enter image description here

setWebpackOptimizationSplitChunks can run normally if this function is removed.

react version is 18.2.0

Upvotes: 0

Views: 68

Answers (0)

Related Questions