diff --git a/docs/deploy/getting-started.md b/docs/deploy/getting-started.md index b9fb66276..37f213201 100644 --- a/docs/deploy/getting-started.md +++ b/docs/deploy/getting-started.md @@ -88,3 +88,37 @@ We'll create the function and a `package.json` in your project output directory. ## Step 3: customization To customize the deployment flow, you can use the configuration files you're already familiar with from `firebase-tools`. You can find more in the [firebase documentation](https://firebase.google.com/docs/hosting/full-config). + +### Configuration Options + +If you have multiple build targets and deploy targets, it is possible to specify them in your `angular.json` or `workspace.json`. + +It is possible to use either your project name or project alias in `firebaseProject`. The setting provided here is equivalent to passing a project name or alias to `firebase deploy --project projectNameOrAlias`. The uppercase `-P` flag is also an alias for `--project` when using Firebase CLI. + +The `buildTarget` simply points to an existing build configuration for your project. Most projects have a default configuration and a production configuration (commonly activated by using the `--prod` flag) but it is possible to specify as many build configurations as needed. + +You may specify a `buildTarget` and `firebaseProject` in your `options` as follows: + +```json +"deploy": { + "builder": "@angular/fire:deploy", + "options": { + "buildTarget": "projectName:build", + "firebaseProject": "developmentProject" + }, + "configurations": { + "production": { + "buildTarget": "projectName:build:production", + "firebaseProject": "productionProject" + } + } +} +``` + +The above configuration specifies the following: + +1. `ng deploy` will deploy the default project with default configuration. +2. `ng deploy projectName` will deploy the specified project with default configuration. +3. `ng deploy projectName --prod` or `ng deploy projectName --configuration='production'` will deploy `projectName` with production build settings to your production environment. + +All of the options are optional. If you do not specify a `buildTarget`, it defaults to a production build (`projectName:build:production`). If you do not specify a `firebaseProject`, it defaults to the first matching deploy target found in your `.firebaserc` (where your projectName is the same as your Firebase deploy target name). The `configurations` section is also optional. diff --git a/src/schematics/deploy/actions.ts b/src/schematics/deploy/actions.ts index 0a7bab9bf..e9cde98cd 100644 --- a/src/schematics/deploy/actions.ts +++ b/src/schematics/deploy/actions.ts @@ -236,6 +236,7 @@ export default async function deploy( try { await firebaseTools.use(firebaseProject, { project: firebaseProject }); + context.logger.info(`🔥 Your configured Firebase project is '${firebaseProject}'`); } catch (e) { throw new Error(`Cannot select firebase project '${firebaseProject}'`); } diff --git a/src/schematics/deploy/builder.ts b/src/schematics/deploy/builder.ts index b47b9e130..fdfe97ea6 100644 --- a/src/schematics/deploy/builder.ts +++ b/src/schematics/deploy/builder.ts @@ -27,7 +27,7 @@ export default createBuilder( const projectTargets = workspace.getProjectTargets(context.target.project); - const firebaseProject = getFirebaseProjectName( + const firebaseProject = options.firebaseProject || getFirebaseProjectName( context.workspaceRoot, context.target.project ); diff --git a/src/schematics/deploy/schema.json b/src/schematics/deploy/schema.json index a48deed07..2a49ab81c 100644 --- a/src/schematics/deploy/schema.json +++ b/src/schematics/deploy/schema.json @@ -9,6 +9,10 @@ "description": "Target to build.", "pattern": "^[^:\\s]+:[^:\\s]+(:[^\\s]+)?$" }, + "firebaseProject": { + "type": "string", + "description": "The Firebase project name or project alias to use when deploying" + }, "preview": { "type": "boolean", "description": "Do not deploy the application, just set up the Firebase Function in the project output directory. Can be used for testing the Firebase Function with `firebase serve`." diff --git a/src/schematics/interfaces.ts b/src/schematics/interfaces.ts index f3d2eda83..64534c305 100644 --- a/src/schematics/interfaces.ts +++ b/src/schematics/interfaces.ts @@ -59,6 +59,7 @@ export interface FirebaseRc { export interface DeployBuilderSchema { buildTarget?: string; + firebaseProject?: string; preview?: boolean; universalBuildTarget?: string; ssr?: boolean;