From 052331fabc445e583a586e81fd275fde09fe5256 Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Mon, 12 Jun 2017 23:51:39 +0100 Subject: [PATCH] build(aio): add staging environment You can now specify what environment you are building by add it to the `yarn build` command. For example: ``` yarn build -- --env=stage ``` Moreover the `deploy-to-firebase.sh` script will automatically apply the appropriate environment. --- aio/.angular-cli.json | 1 + aio/package.json | 4 +++- aio/scripts/deploy-to-firebase.sh | 4 +++- aio/src/environments/environment.prod.ts | 1 + aio/src/environments/environment.stage.ts | 5 +++++ 5 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 aio/src/environments/environment.stage.ts diff --git a/aio/.angular-cli.json b/aio/.angular-cli.json index 20bb848a33..6b3ef2df2f 100644 --- a/aio/.angular-cli.json +++ b/aio/.angular-cli.json @@ -31,6 +31,7 @@ "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", + "stage": "environments/environment.stage.ts", "prod": "environments/environment.prod.ts" } } diff --git a/aio/package.json b/aio/package.json index 4ee6adcfb8..ec01c06780 100644 --- a/aio/package.json +++ b/aio/package.json @@ -8,7 +8,9 @@ "scripts": { "ng": "yarn check-env && ng", "start": "yarn check-env && ng serve", - "build": "yarn check-env && yarn setup && ng build -prod -sm -vc=false && yarn sw-manifest && yarn sw-copy", + "prebuild": "yarn check-env && yarn setup", + "build": "ng build -prod -sm -vc=false", + "postbuild": "yarn sw-manifest && yarn sw-copy", "lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint", "test": "yarn check-env && ng test", "pree2e": "yarn ~~update-webdriver", diff --git a/aio/scripts/deploy-to-firebase.sh b/aio/scripts/deploy-to-firebase.sh index 36f14f288d..bbfa54ab01 100755 --- a/aio/scripts/deploy-to-firebase.sh +++ b/aio/scripts/deploy-to-firebase.sh @@ -8,11 +8,13 @@ readonly deployEnv=$1 case $deployEnv in staging) + readonly buildEnv=stage readonly projectId=aio-staging readonly deployedUrl=https://$projectId.firebaseapp.com/ readonly firebaseToken=$FIREBASE_TOKEN ;; production) + readonly buildEnv=prod readonly projectId=angular-io readonly deployedUrl=https://angular.io/ readonly firebaseToken=$FIREBASE_TOKEN @@ -27,7 +29,7 @@ esac cd "`dirname $0`/.." # Build the app - yarn build + yarn build -- --env=$buildEnv # Deploy to Firebase firebase use "$projectId" --token "$firebaseToken" diff --git a/aio/src/environments/environment.prod.ts b/aio/src/environments/environment.prod.ts index f87f947c47..0f5ad5b335 100644 --- a/aio/src/environments/environment.prod.ts +++ b/aio/src/environments/environment.prod.ts @@ -1,3 +1,4 @@ +// This is for the production site, which is hosted at https://angular.io export const environment = { gaId: 'UA-8594346-15', production: true diff --git a/aio/src/environments/environment.stage.ts b/aio/src/environments/environment.stage.ts new file mode 100644 index 0000000000..97a992c88f --- /dev/null +++ b/aio/src/environments/environment.stage.ts @@ -0,0 +1,5 @@ +// This is for the staging site, which is hosted at https://aio-staging.firebaseapp.org +export const environment = { + gaId: 'UA-8594346-26', + production: true +};