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

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

藏色散人
Release: 2023-02-20 16:32:08
Original
2669 people have browsed it

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
Copy after login

2. Use

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

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template