I am working with Ionic 4 project. I have different environments(test, testB, prob, dev ecc..). I have created all the file inside the environment folder: environment.dev.ts, environment.testA.ts, environment.testB.ts etc. Is there any way to set the correct environment while building or serving(on the browser) the project(maybe something like --env=testA like angular?)? Only thing I can find is --prod, which is only for the production environment, but in this case, I have more than 2 environments.
You should check your package.json file.
My package.json looks like the following:
"name": "name",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-prod": "ng build --prod --progress false",
"build-dev": "ng build --env=dev --aot=true --output-hashing=all --sourcemaps=false --extract-css=true --named-chunks=false --build-optimizer=true --progress false",
"build-preprod": "ng build --env=preprod --aot=true --output-hashing=all --sourcemaps=false --extract-css=true --named-chunks=false --build-optimizer=true --progress false",
"build-dev2": "ng build --env=dev2 --aot=true --output-hashing=all --sourcemaps=false --extract-css=true --named-chunks=false --build-optimizer=true --progress false"
},
In angular-cli.json there is an environment key:
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts",
"preprod": "environments/environment.preprod.ts",
"dev2": "environments/environment.dev2.ts"
},
In Angular 8 you should check angular.json:
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}, "preprod": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.preprod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
}
}
},
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With