Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 反应中的构建时间过长(10分钟)_Reactjs_Create React App_React Scripts - Fatal编程技术网

Reactjs 反应中的构建时间过长(10分钟)

Reactjs 反应中的构建时间过长(10分钟),reactjs,create-react-app,react-scripts,Reactjs,Create React App,React Scripts,其中一个react应用程序构建生产内容花费的时间太长 package.json的内容如下 { "name": "app", "version": "1.0.0", "private": true, "dependencies": { "@date-io/date-fns": "^1.3.13", "

其中一个react应用程序构建生产内容花费的时间太长

package.json的内容如下

{
  "name": "app",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@date-io/date-fns": "^1.3.13",
    "@date-io/moment": "^1.3.13",
    "@material-ui/core": "^4.9.7",
    "@material-ui/icons": "^4.9.1",
    "@material-ui/lab": "^4.0.0-alpha.46",
    "@material-ui/pickers": "^3.2.10",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/react": "^16.9.53",
    "axios": "0.19.2",
    "clsx": "^1.1.0",
    "currency-formatter": "^1.5.5",
    "date-fns": "^2.0.0-beta.5",
    "env-cmd": "^10.1.0",
    "file-saver": "^2.0.2",
    "human-format": "^0.11.0",
    "jwt-decode": "^2.2.0",
    "lodash": "^4.17.15",
    "material-table": "^1.69.1",
    "material-ui-chip-input": "^2.0.0-beta.2",
    "moment": "^2.24.0",
    "numeral": "^2.0.6",
    "password-validator": "^5.0.3",
    "plotly.js": "^1.53.0",
    "query-string": "^6.12.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-google-charts": "^3.0.15",
    "react-plotly.js": "^2.4.0",
    "react-preloaders": "^3.0.3",
    "react-redux": "^7.2.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^3.4.3",
    "react-window": "^1.8.5",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0",
    "validate.js": "^0.13.1",
    "xlsx": "^0.16.1"
  },
  "scripts": {
    "start": "env-cmd -f .env.development react-scripts --max_old_space_size=4096 start",
    "build": "react-scripts --max_old_space_size=4096 build",
    "build:prod": "env-cmd -f .env.production react-scripts --max_old_space_size=4096 build",
    "build:test": "env-cmd -f .env.test react-scripts --max_old_space_size=4096 build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@material-ui/styles": "^4.10.0",
    "eslint-plugin-react": "^7.21.5"
  }
}
同样,在github中react上的一个线程之后,实际上开始使用
--max\u old\u space\u size=4096
,出于某种原因,这是很奇怪的,因为我没有使用过任何其他项目,但它们的复杂性几乎相同。其他应用程序在3分钟内就可以正常运行。然而,这个特定的项目需要大约9-10分钟来构建一个生产内容

到目前为止我所做的事情: 删除未使用的导入 仅导入代码所需的特定函数。
构建大小仍然达到3MB,构建时间大约为10分钟

您可以分享更多的代码吗?Github链接还是什么?您是否需要
@测试库/react
库。另外,如果您使用的是弹出版本的
创建react应用程序
@nanoaddam无法共享更多我的代码,我很乐意在您认为可能有问题的地方添加详细信息。对于测试库,我可以将其从prod依赖项中删除,但其他应用程序仍具有更好的性能。因为它是用CRA建造的