* 目次 [#z20d0797] #contents * はじめに [#e8c10739] ngrokで、デプロイできたが、firebaseを使ってデプロイする方法があるらしいのでしらべることにした。 * Firebase Hosting [#fbccba6d] https://firebase.google.com/docs/hosting?hl=ja * 初期化 [#l8d5e59c] firebase init hosting publicディレクトリができる。ダミーのindex.htmlができる * 手順 [#f26fc1c8] flutter build web cd public firebase deploy --only hosting ** firebase.jsonの修正 [#vab9a04b] デフォルトだと、publicフォルダになっているので、flutterのwebビルドのデフォルトの出力先に変更する。 *** 変更後のサンプル [#y7897c3f] { "hosting": { "public": "build/web", "ignore": [ "firebase.json", "**/.*", "**/node_modules/**" ], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } } ** 環境変数を設定した状態でデプロイできるか検証 [#kdc9208a] # build_with_env.sh #!/bin/bash # .env ファイルから環境変数を読み込む export $(cat .env | xargs) # flutter build web コマンドを実行する flutter build web --dart-define=API_URL=$API_URL --dart-define=OTHER_VAR=$OTHER_VAR このスクリプトを使ってビルドする場合: スクリプトファイル(例:build_with_env.sh)を作成します。 スクリプトファイルに実行権限を与えます。 chmod +x build_with_env.sh スクリプトを実行してビルドします。 ./build_with_env.sh * 紹介記事 [#q6c9ea56] ** Hothingの機能を有効化する [#r31362da] https://www.flutter-study.dev/host-web-app/hosting ** Firebase/HostingでWebアプリを外部公開しよう [#f8a311e9] https://qiita.com/my_programming/items/5950b7e27161dc9ec838 ** Firebase HostingでWebサイトをデプロイする [#r43a395f] https://dev.classmethod.jp/articles/firebase-hosting-deploy/ ** HostingでWebアプリ公開 [#b33de1e6] https://www.flutter-study.dev/host-web-app/host-web-app * その他 [#q70058e8] ** Docker上にflutter開発環境を構築する(Linux) [#y16a455f] ** 初心者がFlutterのDocker環境を作る [#caef04dd] https://zenn.dev/citron633/articles/6cb3f390c6c98b ** Docker上にflutter開発環境を構築する(Linux) [#y16a455f] ** https://zenn.dev/ysuito/articles/69af1203be532d [#pd2caa68]