Skip to content

Instantly share code, notes, and snippets.

@md-hamed
Created December 13, 2018 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save md-hamed/9212a32b37e72b1f8fd51136b1e1dfdc to your computer and use it in GitHub Desktop.
Save md-hamed/9212a32b37e72b1f8fd51136b1e1dfdc to your computer and use it in GitHub Desktop.
Simple configurations to be used with Ionic
import * as deepExtend from 'deep-extend';
/**
* Add default configurations here
*/
const DEFAULT_CONFIG = {
config1: 'foo',
config2: {
nestedConfig1: 'dev'
}
// other configs ..
};
/**
* Add development configurations here
*/
const DEV_CONGIF = {
};
/**
* Add production configurations here
*/
const PROD_CONFIG = {
config2: {
nestedConfig1: 'prod'
}
};
// merge both default, development, and production configurations
var _CONFIG;
if (process.env.IONIC_ENV == 'dev') {
_CONFIG = deepExtend(DEFAULT_CONFIG, DEV_CONGIF);
} else if (process.env.IONIC_ENV == 'prod') {
_CONFIG = deepExtend(DEFAULT_CONFIG, PROD_CONFIG);
}
export const CONFIG = _CONFIG;
@remisture
Copy link

How do you use this config in for instance app.module.ts?

import { CONFIG } from 'config';

@NgModule({
	declarations: [MyApp,...],
	imports: [
		...
		AngularFireModule.initializeApp(CONFIG.firebase),
	],
	bootstrap: [IonicApp],
	entryComponents: [MyApp,...],
	providers: [...]
})
export class AppModule {}

Typescript Error
Cannot find name 'process'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment