It looks like Vercel is ignoring my Stage environment variables. It just read the Production environment variables. I committed my changes on stage branch and Vercel is deploying it correctly on Preview(stage) environment, but it don't read my variables. If I run the command below in my computer, everything is working fine(I've tried different things):
npm run build -- --configuration stage
npm run build -- --configuration preview
This is my stage environment file
export const environment = {
production: false,
API_URL: "https://Ichangedthevaluehere",
API_LOGIN: "valuechangedhere",
API_PASSWORD: "valuechangedhere",
NAME: "Stage",
VERCEL_GIT_COMMIT_SHA: "",
};
This is my angular.json file
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"thewordsthatiknow": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss"
},
"@schematics/angular:application": {
"strict": true
}
},
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/thewordsthatiknow",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss",
"node_modules/ngx-toastr/toastr.css"
],
"scripts": []
},
"configurations": {
"preview": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.preview.ts"
}
]
},
"production": {
"budgets": [
{
"type": "initial",
"maximumWarning": "500kb",
"maximumError": "1mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kb",
"maximumError": "8kb"
}
],
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"outputHashing": "all"
},
"development": {
"buildOptimizer": false,
"optimization": false,
"vendorChunk": true,
"extractLicenses": false,
"sourceMap": true,
"namedChunks": true
}
},
"defaultConfiguration": "production"
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"configurations": {
"preview": {
"browserTarget": "thewordsthatiknow:build:preview"
},
"production": {
"browserTarget": "thewordsthatiknow:build:production"
},
"development": {
"browserTarget": "thewordsthatiknow:build:development"
}
},
"defaultConfiguration": "development"
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "thewordsthatiknow:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss",
"node_modules/ngx-toastr/toastr.css"
],
"scripts": []
}
}
}
}
},
"defaultProject": "thewordsthatiknow"
}
So, do you guys have look to deploy an angular app to Vercel with a stage environment?