$ npm run build
- React製WebアプリのAWSへのdeploy scriptを作った試行錯誤の過程 - Qiita
- AWS S3にアップロードしてCloudFrontでホストしたらいいらしい
- 説明は自動化に関してだが、とりあえず1回手動でやってから考えたい
- AWS S3で静的Webページをホスティングする - Qiita
- HTTPならCloudFrontは必要ないらしい
- S3にドラッグドロップでアップロード
- 最初はbuildディレクトリを単独でアップロードした
- npm run buildで作られたbuildが
/static/foo.js
みたいな参照をしているのでブラウザで/build/index.htmlを開いてもそこからのJSのロードで失敗する - これはこういうこと :
- npm run buildで作られたbuildが
The project was built assuming it is hosted at the server root.
You can control this with the homepage field in your package.json.
For example, add this to build it for GitHub Pages:
"homepage" : "http://myname.github.io/myapp",
- buildディレクトリの中身をバケットのルートに配置
- →できた
デプロイ作業の自動化 CloudFront に S3 bucket のサブディレクトリパスのコンテンツを参照させる - Qiita