firebase-module
firebase-module copied to clipboard
feat: add runtime config support
- Closes #443
Merges the config found in publicRuntimeConfig.firebase with the module options, I don't think this works if you add the module to buildModules.
Adds functionality to compile/generate templates on startup, maybe there is a better way that doesn't require adding lodash and serialize-javascript as dependencies. The compilation also makes the assumption that the nuxt template global is always set to $nuxt, this can probably be cached/saved at build time for accuracy.
For dynamic configs the usage could be as follows
publicRuntimeConfig: {
firebase:
process.env.CUSTOM_ENV_VARIABLE === 'production' ?
// Production config
{
apiKey: '...',
authDomain: '...',
projectId: '...',
storageBucket: '...',
messagingSenderId: '...',
appId: '...',
measurementId: '...',
} :
// Development config
{
apiKey: '...',
authDomain: '...',
projectId: '...',
storageBucket: '...',
messagingSenderId: '...',
appId: '...',
measurementId: '...',
},
}
To me this seems a bit easier or more flexible than the customEnv key and the nested environment configs. I suggest removing that approach if this feature gets added as the same can be achieved with runtime config and it could cause confusion/conflicts if nested configs are used in combination with runtime config.
My implementation feels a bit hacky to me, so please let me know if there are any changes to be made! 😄