apo*_*llo 6 javascript reactjs webpack
当我将 React 项目部署到 Surge 中时,构建成功并且可以获取应用程序 URL。但是当我链接到 URL 时,我可以在检查控制台中看到一个空白页面和一些错误:
Failed to load resource: the server responded with a status of 404 (Not Found) 3.138a0231.chunk.css
Failed to load resource: the server responded with a status of 404 (Not Found) main.bd0d3f99.chunk.js:1
Failed to load resource: the server responded with a status of 404 (Not Found) main.bd0d3f99.chunk.css:1
Failed to load resource: the server responded with a status of 404 (Not Found)
Failed to load resource: the server responded with a status of 404 (Not Found)
Failed to load resource: the server responded with a status of 404 (Not Found) manifest.json:1
Manifest: Line: 1, column: 1, Syntax error. manifest.json:1
Failed to load resource: the server responded with a status of 404 (Not Found) 3.138a0231.chunk.css
Failed to load resource: the server responded with a status of 404 (Not Found) 3.138a0231.chunk.css
Failed to load resource: the server responded with a status of 404 (Not Found) main.bd0d3f99.chunk.css:1
Run Code Online (Sandbox Code Playgroud)
这是我的文件中的反应启动脚本package.json。
"scripts": {
"build": "REACT_APP_BACKEND=true PUBLIC_URL='/sing-app-react' node scripts/build.js",
"start": "node scripts/start.js",
"start:backend": "REACT_APP_BACKEND=true node scripts/start.js",
"test": "node scripts/test.js"
},
Run Code Online (Sandbox Code Playgroud)
以及导致错误的css文件的链接地址https://lopsided-dinner.surge.sh/sing-app-react/static/css/3.138a0231.chunk.css
小智 4
https://lopsided-dinner.surge.sh/sing-app-react/static/css/3.138a0231.chunk.css
这个由 React 脚本构建的网站 url 应该是这样的https://your domain/static/css...
删除构建脚本中的 PUBLIC_URL 并再次运行构建。
它将构建源引导至 /static/....
希望这对你有意义!
| 归档时间: |
|
| 查看次数: |
29580 次 |
| 最近记录: |