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.
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
in the project. , exceptions are often reported when packaging, and packaging is unsuccessful
1. Problems that occur during packaging
##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 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!