feat: support runtimeConfig (closes #43)

This commit is contained in:
Pooya Parsa 2020-11-28 21:50:02 +01:00
parent 5783abdb52
commit ca015deda6
2 changed files with 8 additions and 2 deletions

View File

@ -46,6 +46,7 @@ export interface SigmaContext {
isStatic: boolean
fullStatic: boolean
staticAssets: any
runtimeConfig: { public: any, private: any }
}
_internal: {
runtimeDir: string
@ -93,7 +94,11 @@ export function getsigmaContext (nuxtOptions: NuxtOptions, input: SigmaInput): S
isStatic: nuxtOptions.target === 'static' && !nuxtOptions.dev,
fullStatic: nuxtOptions.target === 'static' && !nuxtOptions._legacyGenerate,
// @ts-ignore
staticAssets: nuxtOptions.generate.staticAssets
staticAssets: nuxtOptions.generate.staticAssets,
runtimeConfig: {
public: nuxtOptions.publicRuntimeConfig,
private: nuxtOptions.privateRuntimeConfig
}
},
_internal: {
runtimeDir: resolve(__dirname, '../runtime'),

View File

@ -105,7 +105,8 @@ export const getRollupConfig = (sigmaContext: SigmaContext) => {
'process.env.NUXT_STATIC_BASE': JSON.stringify(sigmaContext._nuxt.staticAssets.base),
'process.env.NUXT_STATIC_VERSION': JSON.stringify(sigmaContext._nuxt.staticAssets.version),
'process.env.NUXT_FULL_STATIC': sigmaContext._nuxt.fullStatic as unknown as string,
'process.env.SIGMA_PRESET': JSON.stringify(sigmaContext.preset)
'process.env.SIGMA_PRESET': JSON.stringify(sigmaContext.preset),
'process.env.RUNTIME_CONFIG': JSON.stringify(sigmaContext._nuxt.runtimeConfig)
}
}))