React 构建与开发有很大不同
谢谢你想尝试帮助我!
当我构建 React Web 应用程序时,它看起来与开发模式非常不同。我使用 serve -s build
来观察应用程序的构建时间。但在我的在线 Digitalocean 服务器上,它看起来也不会与开发中的一样。所以它可能与 React 或者它的构建方式有关。 这是在开发模式下:
所以看起来 CSS 或 Javacript 没有正确编译。 这是我的 package.json
{
"name": "websitedominique",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@mui/icons-material": "^5.2.1",
"@mui/material": "^5.4.2",
"@mui/styled-engine-sc": "^5.4.2",
"@react-hook/mouse-position": "^4.1.3",
"@rehooks/window-size": "^1.0.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"concurrently": "^7.0.0",
"cors": "^2.8.5",
"express": "^4.17.3",
"framer-motion": "^4.1.17",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^6.0.2",
"react-router-dom": "^6.0.2",
"react-scripts": "4.0.3",
"styled-components": "^5.3.3",
"swiper": "^6.8.4",
"use-react-dimensions": "^2.0.1",
"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": {
"nodemon": "^2.0.15"
}
}
我希望有人可以帮助我。感谢您的帮助!
Thanks you want to try to help me!
When I build my React web app it looks very different from the development mode. I use serve -s build
to watch when the app is build. But also on my online Digitalocean server, it won't look the same as in development. So it probably has something to do with React or how it was build.
This is in development mode:
So it looks CSS or Javacript did not compile correctly.
This is my package.json
{
"name": "websitedominique",
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@mui/icons-material": "^5.2.1",
"@mui/material": "^5.4.2",
"@mui/styled-engine-sc": "^5.4.2",
"@react-hook/mouse-position": "^4.1.3",
"@rehooks/window-size": "^1.0.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"concurrently": "^7.0.0",
"cors": "^2.8.5",
"express": "^4.17.3",
"framer-motion": "^4.1.17",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-router": "^6.0.2",
"react-router-dom": "^6.0.2",
"react-scripts": "4.0.3",
"styled-components": "^5.3.3",
"swiper": "^6.8.4",
"use-react-dimensions": "^2.0.1",
"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": {
"nodemon": "^2.0.15"
}
}
I Hope someone can help me with this. Thanks for all help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在根目录中添加一个 .env 文件并添加:
REACT_APP_SC_DISABLE_SPEEDY=true
样式组件库使用称为“快速模式”的东西在生产中注入样式。你可以谷歌它以获取更多信息
you should add a .env file in your root and add:
REACT_APP_SC_DISABLE_SPEEDY=true
The Styled Components library uses something called the "Speedy mode" to inject styles on production. you can Google it for more info