create-react-app 在构建之后,页面性能下降,React版本为^17.0.37,

yruzcnhs  于 5个月前  发布在  React
关注(0)|答案(3)|浏览(70)

我今天刚刚用这个命令创建了代码框架。

npx create-react-app my-app
cd my-app
npm start

在开发模式下,我的代码和页面性能还可以。平均50帧每秒。只有几个requestAnimationFrame警告
但是在构建后,页面性能下降,只有大约15帧每秒,错误[Violation] 'requestAnimationFrame' handler 用时 <N> 毫秒没有停止。
正常,开发环境:

错误,构建环境:

http://zyzx.jingge.com:45231/releases/%E7%BA%AF%E7%94%B5%E5%8A%A8%E6%B1%BD%E8%BD%A6%E4%BA%A4%E6%B5%81%E5%85%85%E7%94%B5%E7%B3%BB%E7%BB%9F3D%E7%BB%93%E6%9E%84%E5%B1%95%E7%A4%BA/index.html
package.json

{
  "name": "w3dres-web-cra-three",
  "homepage": ".",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "@types/jest": "^27.0.3",
    "@types/node": "^16.11.11",
    "@types/react": "^17.0.37",
    "@types/react-dom": "^17.0.11",
    "antd": "^4.17.2",
    "axios": "^0.24.0",
    "gsap": "^3.8.0",
    "hox": "^1.1.4",
    "mitt": "^3.0.0",
    "react": "^17.0.2",
    "react-device-detect": "^2.1.2",
    "react-dom": "^17.0.2",
    "react-helmet-async": "^1.1.2",
    "react-scripts": "4.0.3",
    "three": "^0.134.0",
    "three-spritetext": "^1.6.3",
    "typescript": "^4.5.2",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@types/three": "^0.134.0"
  }
}

------------------------2021-12-02---------------------------------------------------------------------
感觉像是压缩插件的问题
umijs/umi#7644

kr98yfug

kr98yfug1#

同样的问题在这里

vawmfj5a

vawmfj5a2#

我也在经历这个问题。我发现将生产环境的browserlist设置为与开发环境相同,这对我来说已经解决了问题。

f1tvaqid

f1tvaqid3#

我也在经历这个问题。我发现将生产环境的browserlist设置为与开发环境相同,这对我来说解决了问题。

"browserslist": {
    "production": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },

我试过了,但对我不起作用!@jaminmelville

相关问题