s3 中托管的 React 应用程序在部署后不会更新

问题描述 投票:0回答:2

我有一个使用 CloudFront 在 S3 上托管的网站。我已经部署了几次并工作,但现在部署后它不会更新 s3 存储桶。我使用

npm audit fix
检查依赖关系并修复依赖关系。此外,我使用了
npm cache clean --force
并删除了
package-lock.json
,之后我部署了它,但它也不起作用。

部署时使用的命令:

npm run build && aws s3 sync build/ s3://host

package.json

{
  "name": "dashboard",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fnando/cpf": "^0.1.1",
    "@rocketseat/unform": "^1.5.1",
    "axios": "^0.19.0",
    "date-fns": "^2.14.0",
    "history": "^4.9.0",
    "immer": "^3.2.0",
    "lodash": "^4.17.20",
    "polished": "^3.4.1",
    "prop-types": "^15.7.2",
    "react": "^16.9.0",
    "react-datepicker": "^2.16.0",
    "react-dom": "^16.9.0",
    "react-icons": "^3.7.0",
    "react-redux": "^7.1.0",
    "react-router-dom": "^5.1.2",
    "react-scripts": "^3.4.3",
    "react-select": "^3.0.4",
    "react-skeleton-loader": "^1.0.4",
    "react-toastify": "^5.3.2",
    "reactotron-react-js": "^3.3.2",
    "reactotron-redux": "^3.1.1",
    "reactotron-redux-saga": "^4.2.2",
    "redux": "^4.0.4",
    "redux-persist": "^5.10.0",
    "redux-saga": "^1.0.5",
    "styled-components": "^4.3.2",
    "yup": "^0.27.0"
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "react-app-rewired build",
    "test": "react-app-rewired test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "babel-plugin-root-import": "^6.4.1",
    "customize-cra": "^0.5.0",
    "prettier": "^1.18.2",
    "react-app-rewired": "^2.1.3"
  }
}
reactjs amazon-s3 react-redux amazon-cloudfront
2个回答
1
投票

Cloudfront 可能缓存了之前的部署。

您可以更改缓存设置以完全禁用缓存,或者对您的发行版运行失效以有效清除缓存。

aws cloudfront create-invalidation --distribution-id distribution_ID --paths "/*"

0
投票

创建失效规则,用于清除存储在边缘位置的缓存 enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.