{"action":"closed","issue":{"url":"https://api.github.com/repos/facebook/create-react-app/issues/5356","repository_url":"https://api.github.com/repos/facebook/create-react-app","labels_url":"https://api.github.com/repos/facebook/create-react-app/issues/5356/labels{/name}","comments_url":"https://api.github.com/repos/facebook/create-react-app/issues/5356/comments","events_url":"https://api.github.com/repos/facebook/create-react-app/issues/5356/events","html_url":"https://github.com/facebook/create-react-app/issues/5356","id":367888127,"node_id":"MDU6SXNzdWUzNjc4ODgxMjc=","number":5356,"title":"homepage in package.json makes versioning workflow complicated","user":{"login":"nicgirault","id":551837,"node_id":"MDQ6VXNlcjU1MTgzNw==","avatar_url":"https://avatars3.githubusercontent.com/u/551837?v=4","gravatar_id":"","url":"https://api.github.com/users/nicgirault","html_url":"https://github.com/nicgirault","followers_url":"https://api.github.com/users/nicgirault/followers","following_url":"https://api.github.com/users/nicgirault/following{/other_user}","gists_url":"https://api.github.com/users/nicgirault/gists{/gist_id}","starred_url":"https://api.github.com/users/nicgirault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicgirault/subscriptions","organizations_url":"https://api.github.com/users/nicgirault/orgs","repos_url":"https://api.github.com/users/nicgirault/repos","events_url":"https://api.github.com/users/nicgirault/events{/privacy}","received_events_url":"https://api.github.com/users/nicgirault/received_events","type":"User","site_admin":false},"labels":[{"id":1113224076,"node_id":"MDU6TGFiZWwxMTEzMjI0MDc2","url":"https://api.github.com/repos/facebook/create-react-app/labels/stale","name":"stale","color":"f4d37f","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2018-10-08T17:37:55Z","updated_at":"2018-11-09T18:18:13Z","closed_at":"2018-11-09T18:18:13Z","author_association":"NONE","body":"## The problem\r\n\r\nThe users on my SPA (with code splitting) are getting 404 on code chunks when I deploy a new version of the SPA while there are using it.\r\n\r\n## The way I try to fix this\r\n\r\nMy SPA is stored on a S3 bucket with a CloudFront distribution in front of it.\r\n\r\nCurrently I upload the `build` folder at the root of the bucket (and deleting the old version):\r\n\r\n```\r\naws s3 sync build $S3_BUCKET --delete\r\n```\r\n\r\n```\r\nindex.html\r\nstatic\r\n  js\r\n    main.[hash].js\r\n...\r\n```\r\n\r\nThe target would be\r\n\r\n```\r\nindex.html\r\nv1\r\n  static\r\n    js\r\n      main.[hash].js\r\nv2\r\n  static\r\n    js\r\n      main.[hash].js\r\n...\r\n```\r\n\r\nSo that the old version remains available for the connected users.\r\n\r\nTo do so, I set the `homepage` attribute of the `package.json` during the continous integration:\r\n\r\n```javascript\r\n// update-version.js\r\nconst packageJSON = require('./package.json')\r\nconst fs = require('fs')\r\n\r\nconst version = process.env.VERSION\r\npackageJSON['homepage'] = `https://example.com/${version}`\r\n\r\nfs.writeFileSync('package.json', JSON.stringify(packageJSON))\r\n```\r\n\r\nThen I deploy by doing:\r\n\r\n```bash\r\nexport VERSION=v2\r\nnode update-version\r\nreact-scripts build\r\naws s3 sync build $S3_BUCKET/$VERSION --delete --cache-control \"public, max-age=31556926\" --exclude index.html\r\naws s3 cp --cache-control \"public, no-cache\" build/index.html $S3_BUCKET\r\n```\r\n\r\nAlso this works well, I wanted to share my use case to explain that the way to define the server path can be dynamic and thus the homepage seems inapropriate here.\r\n\r\nIt would be more straight forward to be able to use a env variable to do what is written here:\r\n\r\nhttps://github.com/facebook/create-react-app/blob/4562ab6fd80c3e18858b3a9a3828810944c35e36/packages/react-scripts/config/paths.js#L33-L47\r\n\r\nso that I can write:\r\n\r\n```bash\r\nSERVER_PATH=/v2 react-scripts build\r\n```\r\n\r\nDo you think the way I solve my problem is inapropriate? What do you think about a pull request allowing to set a env variable to define the server path?"}}
{"actor":{"display_login":"bugzpodder"}}