Last active
July 26, 2019 04:33
-
-
Save tabirkeland/a17c67b2f1ea3331d94db34ed7191c34 to your computer and use it in GitHub Desktop.
Ionic 3.9.2 Environment Variables
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export interface Environment { | |
DEBUG : boolean; | |
API_URL : string; | |
WS_URL : string; | |
BASE_URL : string; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Environment } from './environment.interface'; | |
export const ENV: Environment = { | |
DEBUG : true, | |
WS_URL : 'ws://10.1.1.1/', | |
API_URL : 'http://10.1.1.1/api/' | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var defaultConfig = require('@ionic/app-scripts/config/optimization.config.js'); | |
const DEV_ENV = './src/environments/environment.ts'; | |
const PROD_ENV = './src/environments/environment.prod.ts'; | |
const devAlias = { | |
"@app/env" : path.resolve(DEV_ENV) | |
}; | |
const prodAlias = { | |
"@app/env" : path.resolve(PROD_ENV) | |
}; | |
module.exports = function () { | |
defaultConfig.dev.resolve.alias = devAlias; | |
defaultConfig.prod.resolve.alias = prodAlias; | |
return defaultConfig; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"config": { | |
"ionic_aot_write_to_disk": true, | |
"ionic_optimization": "./config/optimization.config.js", | |
"ionic_webpack": "./config/webpack.config.js" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"compilerOptions": { | |
"allowSyntheticDefaultImports": true, | |
"declaration": false, | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"lib": [ | |
"dom", | |
"es2015" | |
], | |
"module": "es2015", | |
"moduleResolution": "node", | |
"sourceMap": true, | |
"target": "es5", | |
"baseUrl" : "./src", | |
"paths" : { | |
"@app/env" : [ | |
"environments/environment" | |
] | |
} | |
}, | |
"include": [ | |
"src/**/*.ts" | |
], | |
"exclude": [ | |
"node_modules" | |
], | |
"compileOnSave": false, | |
"atom": { | |
"rewriteTsconfig": false | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
var defaultConfig = require('@ionic/app-scripts/config/webpack.config.js'); | |
const DEV_ENV = './src/environments/environment.ts'; | |
const PROD_ENV = './src/environments/environment.prod.ts'; | |
const devAlias = { | |
"@app/env" : path.resolve(DEV_ENV) | |
}; | |
const prodAlias = { | |
"@app/env" : path.resolve(PROD_ENV) | |
}; | |
module.exports = function () { | |
defaultConfig.dev.resolve.alias = devAlias; | |
defaultConfig.prod.resolve.alias = prodAlias; | |
return defaultConfig; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have implemented files as you mentioned above. when I run "ionic cordova build android --env=dev" or "ionic cordova build android --prod --env=dev" or "ionic cordova build android --prod --env=prod" or "ionic cordova build android --prod", all the time ENV.mode returning DEV.
I imported like this "import { ENV } from '../../environments/environment';" into my home page.
if I import like this "**import { ENV } from '@app/env'; **", IONIC CORDOVA BUILD ANDROID --env=dev is giving me below error, app-scripts are already installed.


Could you please advise me