Home  >  Article  >  Web Front-end  >  What should I do if react packaging and compression is too slow?

What should I do if react packaging and compression is too slow?

藏色散人
藏色散人Original
2022-12-29 09:30:382600browse

Solution to the problem that react packaging and compression is too slow: 1. Use the "npm install hard-source-webpack-plugin" command to install "hard-source-webpack-plugin"; 2. Execute "new HardSourceWebpackPlugin()" statement; 3. Modify "max_old_space_size" in the scripts of the package.json file.

What should I do if react packaging and compression is too slow?

The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.

What should I do if the packaging and compression of react is too slow?

The react project is too big, the packaging speed is very slow and the packaging often fails.

1. Solve the problem of slow packaging

1. Use plug-in: hard -source-webpack-plugin

npm install hard-source-webpack-plugin 或 yarn add hard-source-webpack-plugin

2. Use

const HardSourceWebpackPlugin = require('hard-source-webpack-plugin');
module.exports = {
  // ......
  plugins: [
    new HardSourceWebpackPlugin() // <- 直接加入这行代码就行
  ]
}

3 in the webpack configuration file. Use

What should I do if react packaging and compression is too slow?

in the project. , exceptions are often reported when packaging, and packaging is unsuccessful

1. Problems that occur during packaging

What should I do if react packaging and compression is too slow?

##When packaging, ELIFECYCLE exceptions are often reported, from I searched for this problem online and found no relevant solution. I carefully studied the error message and found the line nodiot-fusiondesgin-demo@0.1.0 build: `react-app-rewired --max_old_space_size=4096 build` There may be a problem, and then I found the place to configure this information in the project, in the scripts of the package.json file

What should I do if react packaging and compression is too slow?

2. Solution:

Change `max_old_space_size=4096` to `max_old_space_size=8192`. After the change, it can be packaged normally after several tests, and the error will not occur

Recommended learning: "

react video tutorial

The above is the detailed content of What should I do if react packaging and compression is too slow?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn