Initial commit
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
# Hosting Configuration (`firebase.json`)
|
||||
|
||||
The `hosting` section of `firebase.json` configures how your site is deployed and served.
|
||||
|
||||
## Key Attributes
|
||||
|
||||
### `public` (Required)
|
||||
Specifies the directory to deploy to Firebase Hosting.
|
||||
```json
|
||||
"hosting": {
|
||||
"public": "public"
|
||||
}
|
||||
```
|
||||
|
||||
### `ignore` (Optional)
|
||||
Files to ignore on deploy. Uses glob patterns (like `.gitignore`).
|
||||
**Default ignores:** `firebase.json`, `**/.*`, `**/node_modules/**`
|
||||
|
||||
### `redirects` (Optional)
|
||||
URL redirects to prevent broken links or shorten URLs.
|
||||
```json
|
||||
"redirects": [
|
||||
{
|
||||
"source": "/foo",
|
||||
"destination": "/bar",
|
||||
"type": 301
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### `rewrites` (Optional)
|
||||
Serve the same content for multiple URLs, useful for SPAs or Dynamic Content.
|
||||
```json
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "**",
|
||||
"destination": "/index.html"
|
||||
},
|
||||
{
|
||||
"source": "/api/**",
|
||||
"function": "apiFunction"
|
||||
},
|
||||
{
|
||||
"source": "/container/**",
|
||||
"run": {
|
||||
"serviceId": "helloworld",
|
||||
"region": "us-central1"
|
||||
}
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### `headers` (Optional)
|
||||
Custom response headers.
|
||||
```json
|
||||
"headers": [
|
||||
{
|
||||
"source": "**/*.@(eot|otf|ttf|ttc|woff|font.css)",
|
||||
"headers": [
|
||||
{
|
||||
"key": "Access-Control-Allow-Origin",
|
||||
"value": "*"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
### `cleanUrls` (Optional)
|
||||
If `true`, drops `.html` extension from URLs.
|
||||
```json
|
||||
"cleanUrls": true
|
||||
```
|
||||
|
||||
### `trailingSlash` (Optional)
|
||||
Controls trailing slashes in static content URLs.
|
||||
- `true`: Adds trailing slash.
|
||||
- `false`: Removes trailing slash.
|
||||
|
||||
## Full Example
|
||||
|
||||
```json
|
||||
{
|
||||
"hosting": {
|
||||
"public": "dist",
|
||||
"ignore": [
|
||||
"firebase.json",
|
||||
"**/.*",
|
||||
"**/node_modules/**"
|
||||
],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "**",
|
||||
"destination": "/index.html"
|
||||
}
|
||||
],
|
||||
"cleanUrls": true,
|
||||
"trailingSlash": false
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -0,0 +1,39 @@
|
||||
# Deploying to Firebase Hosting
|
||||
|
||||
## Standard Deployment
|
||||
To deploy your Hosting content and configuration to your live site:
|
||||
|
||||
```bash
|
||||
npx -y firebase-tools@latest deploy --only hosting
|
||||
```
|
||||
|
||||
This deploys to your default sites (`PROJECT_ID.web.app` and `PROJECT_ID.firebaseapp.com`).
|
||||
|
||||
## Preview Channels
|
||||
Preview channels allow you to test changes on a temporary URL before going live.
|
||||
|
||||
### Deploy to a Preview Channel
|
||||
```bash
|
||||
npx -y firebase-tools@latest hosting:channel:deploy CHANNEL_ID
|
||||
```
|
||||
Replace `CHANNEL_ID` with a name (e.g., `feature-beta`).
|
||||
This returns a preview URL like `PROJECT_ID--CHANNEL_ID-RANDOM_HASH.web.app`.
|
||||
|
||||
### Expiration
|
||||
Channels expire after 7 days by default. To set a different expiration:
|
||||
```bash
|
||||
npx -y firebase-tools@latest hosting:channel:deploy CHANNEL_ID --expires 1d
|
||||
```
|
||||
|
||||
## Cloning to Live
|
||||
You can promote a version from a preview channel to your live channel without rebuilding.
|
||||
|
||||
```bash
|
||||
npx -y firebase-tools@latest hosting:clone SOURCE_SITE_ID:SOURCE_CHANNEL_ID TARGET_SITE_ID:live
|
||||
```
|
||||
|
||||
**Example:**
|
||||
Clone the `feature-beta` channel on your default site to live:
|
||||
```bash
|
||||
npx -y firebase-tools@latest hosting:clone my-project:feature-beta my-project:live
|
||||
```
|
||||
Reference in New Issue
Block a user