In Angular (Type Script) there are many config files. Which is the right one to save a global setting?
For example, when I am calling API from local then my rootUr
You can use process.env
with webpack quite easily. E.g.
/**
* This interface makes sure we don't miss adding a property to both `prod` and `test`
*/
interface Config {
someItem: string;
}
/**
* We only export a single thing. The config.
*/
export let config: Config;
/**
* `process.env.NODE_ENV` definition is driven from webpack
*
* The whole `else` block will be removed in the emitted JavaScript
* for a production build
*/
if (process.env.NODE_ENV === 'production') {
config = {
someItem: 'prod'
}
console.log('Running in prod');
} else {
config = {
someItem: 'test'
}
console.log('Running in test');
}
and you can change process.env.NODE_ENV
using webpack -p --define process.env.NODE_ENV='\"production\"' --config ./src/webpack.config.js
https://basarat.gitbooks.io/typescript/docs/tips/build-toggles.html