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

react app hosted in s3 doesn't update after deploy

我在 S3 上使用 CloudFront 托管了一个网站。我已经部署了几次并开始工作,但现在它在我部署后不会更新 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"
  }
}

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

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

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