I have multiple Angular configurations.
To extend the default configuration, I use lodash merge:
import { merge } from 'lodash'
import { defaults } from './defaults'
export const configuration = merge(defaults, {
debugApp: 'sp5:auth,sp5:sim-filter-system'
})
However, when I build with the AOT flag this approach is causing problems.
What is the correct approach to extend a configuration?
Try using this
const config = {
debugApp: 'sp5:auth,sp5:sim-filter-system'
};
Object.keys(defaults).forEach(key => config[key] = config[key] ? config[key] : defaults[key]);
export const configuration = config;
This should get all the keys in defaults
, and if you declared them in config
, they will keep their value.