che*_*ist 5 javascript amazon-s3 reactjs webpack react-create-app
我有一个 React 应用程序(使用 React Create App),我想使用脚本将其上传到生产环境。我的产品是 AWS S3 存储桶。我在 package.json 中添加了一个“部署”脚本,如下所示:
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"deploy": "aws s3 cp ./build s3://app.example.com --recursive --exclude \"*.DS_Store\" --cache-control public,max-age=604800 --profile production-profile"
},
Run Code Online (Sandbox Code Playgroud)
这会将所有构建文件上传到生产存储桶。由于构建静态文件(css、js 等)有自己的哈希码,它们不会被每个版本覆盖,这很好。
我遇到的问题是,在其他文件完成上传之前,我不希望上传 index.html 文件。这样,一旦 index.html 被最新版本覆盖,就会自动使用新的静态文件。
知道如何实现这一目标吗?如果有更好的脚本可以将 React 应用程序上传到 S3,那就太好了。
您可以先复制除 index.html 之外的所有内容,然后再复制它。
"aws s3 cp ./build s3://app.example.com --recursive --exclude \"*.DS_Store\" --exclude \"index.html\" --cache-control public,max-age=604800 --profile production-profile && aws s3 cp ./build/index.html s3://app.example.com --cache-control public,max-age=604800 --profile production-profile "
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
934 次 |
| 最近记录: |