I am using the l18n bundle with requirejs. In dev mode I want to pull the locale from local storage. In prod mode I want to do the same. mainConfig.js
:
config: {
i18n: {
locale: localStorage.getItem('locale') || null
}
}
But at build time I do not care about locale, (infact r.js throws an error when parsing the config file). But I can't see any option to overwrite it (r.js/example.build.js).
How can I specify locale like locale: localStorage.getItem('locale') || null
in mainConfig.js
, but no locale at build when buildConfig.js
specifies mainConfigFile: mainConfig.js
?
Solution: don't put the locale spec in mainConfig.js
in the first place, but make another call to require.config
with the locale information. Configs get merged. Be sure to match the context if applicable.