我正在构建的React应用程序有一个manifest.json和一个env.json,如下所示,
但是,当我使用 AWS-Amplify 将网站发布到 S3 存储桶时,manifest.json 和 env.json 会加载我的 index.html。一切都在本地主机中正常工作,但在生产中我们遇到了上一个问题,即使我们可以获取其他文件作为图标和 robots.txt。
我们的公共文件夹的内容如下:
asset-manifest.json
browserconfig.xml
ec4c4f981671b5dee24ab5f541f07720.png
ef7c6637c68f269a882e73bcb57a7f6a.woff2
env.json <----- loading index.html
icons
index.html
main-5fbcf0b95e5bf6891f54.js
main-5fbcf0b95e5bf6891f54.js.LICENSE.txt
manifest.json. <----- loading index.html
robots.txt. <------ working
service-worker.js
Run Code Online (Sandbox Code Playgroud)
amplify.yml 文件如下所示:
version: 0.1
frontend:
phases:
preBuild:
commands:
- npm install
build:
commands:
- NODE_ENV=$MY_ENV_SELECTOR node ./node_modules/webpack/bin/webpack.js --mode production --env=prod
artifacts:
baseDirectory: dist
files:
- '**/*'
cache:
paths:
- node_modules/**/*
Run Code Online (Sandbox Code Playgroud)
看起来它正在为我们提供index.html,因为它没有找到所请求的文件,但我们不知道为什么会发生这种情况。
我们希望任何人都可以帮助我们解决这个问题。