【问题标题】:react app hosted in s3 doesn't update after deploy部署后托管在 s3 中的反应应用程序不会更新
【发布时间】:2021-01-15 14:29:42
【问题描述】:

我有一个使用 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


    【解决方案1】:

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

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-05-22
      • 2013-03-19
      • 2021-05-09
      • 2015-12-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多