Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 29 additions & 24 deletions sites/docs/src/content/deployment/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,7 @@ many others:

## Deploy to Firebase Hosting {:#deploying-to-firebase-hosting}

You can use the Firebase CLI to build and release your Flutter app with Firebase
Hosting.
You can use the Firebase CLI to deploy your Flutter web app to Firebase Hosting.

### Before you begin

Expand All @@ -338,43 +337,50 @@ To get started, [install or update][install-firebase-cli] the Firebase CLI:
npm install -g firebase-tools
```

### Initialize Firebase
<a id="initialize-firebase" aria-hidden="true"></a>

1. Enable the web frameworks preview to the [Firebase framework-aware CLI][]:
### Initialize and deploy

```console
firebase experiments:enable webframeworks
```

2. In an empty directory or an existing Flutter project, run the initialization
command:
1. In the root directory of your Flutter project,
run the initialization command:

```console
firebase init hosting
```

3. Answer `yes` when asked if you want to use a web framework.
1. Follow the CLI prompts:

4. If you're in an empty directory,
you'll be asked to choose your web framework. Choose `Flutter Web`.
* Select an existing Firebase project or create a new project.
* When asked `What do you want to use as your public directory?`,
enter `build/web`.
* Choose whether to configure the site as a single-page application
(rewriting all URLs to `/index.html`).
* Choose whether to set up automatic builds and deploys with GitHub.
* If `build/web/index.html` already exists,
answer `no` when asked whether to overwrite it.

5. Choose your hosting source directory; this could be an existing flutter app.
1. Build your web app for release:

6. Select a region to host your files.
```console
flutter build web
```

7. Choose whether to set up automatic builds and deploys with GitHub.
:::tip
To run `flutter build web` automatically whenever you deploy,
add `"predeploy": ["flutter build web"]` to the `"hosting"` section
of your `firebase.json` file.
For recommended `Cache-Control` headers and
single-page application rewrite rules in `firebase.json`,
check out the [Web FAQ][web-faq-caching].
:::

8. Deploy the app to Firebase Hosting:
1. Deploy the release bundle to Firebase Hosting:

```console
firebase deploy
```

Running this command automatically runs `flutter build web --release`,
so you don't have to build your app in a separate step.

To learn more, visit the official [Firebase Hosting][] documentation for
Flutter on the web.
To learn more, visit the official [Firebase Hosting][] documentation.

## Handle images on the web {:#handling-images-on-the-web}

Expand Down Expand Up @@ -447,8 +453,7 @@ refer to [Add Flutter to any web application][Embedding Flutter web].
[dart-wasm-serving]: {{site.dart-site}}/web/deployment#serving-wasm-in-production
[dhttpd]: {{site.pub}}/packages/dhttpd
[Displaying images on the web]: /platform-integration/web/web-images
[Firebase Hosting]: {{site.firebase}}/docs/hosting/frameworks/flutter
[Firebase framework-aware CLI]: {{site.firebase}}/docs/hosting/frameworks/frameworks-overview
[Firebase Hosting]: {{site.firebase}}/docs/hosting
[install-firebase-cli]: {{site.firebase}}/docs/cli#install_the_firebase_cli
[GitHub Pages]: https://pages.github.com/
[give us feedback]: {{site.repo.flutter}}/issues/new?title=%5Bweb%5D:+%3Cdescribe+issue+here%3E&labels=%E2%98%B8+platform-web&body=Describe+your+issue+and+include+the+command+you%27re+running,+flutter_web%20version,+browser+version
Expand Down
Loading