mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
feat(nitro): #config
This commit is contained in:
parent
f98be4bfed
commit
0b7790f6d0
@ -196,6 +196,7 @@ export const getRollupConfig = (nitroContext: NitroContext) => {
|
||||
entries: {
|
||||
'#nitro': nitroContext._internal.runtimeDir,
|
||||
'#nitro-renderer': require.resolve(resolve(nitroContext._internal.runtimeDir, 'app', renderer)),
|
||||
'#config': require.resolve(resolve(nitroContext._internal.runtimeDir, 'app/config')),
|
||||
'#nitro-vue-renderer': vue2ServerRenderer,
|
||||
'#build': nitroContext._nuxt.buildDir,
|
||||
'~': nitroContext._nuxt.srcDir,
|
||||
|
@ -1,19 +1,16 @@
|
||||
import destr from 'destr'
|
||||
import defu from 'defu'
|
||||
|
||||
const runtimeConfig = process.env.RUNTIME_CONFIG as any
|
||||
// Bundled runtime config
|
||||
export const runtimeConfig = process.env.RUNTIME_CONFIG as any
|
||||
|
||||
// Allow override from process.env and deserialize
|
||||
for (const type of ['private', 'public']) {
|
||||
for (const key in runtimeConfig[type]) {
|
||||
runtimeConfig[type][key] = destr(process.env[key] || runtimeConfig[type][key])
|
||||
}
|
||||
}
|
||||
|
||||
const $config = globalThis.$config = {
|
||||
...runtimeConfig.public,
|
||||
...runtimeConfig.private
|
||||
}
|
||||
|
||||
export default {
|
||||
public: runtimeConfig.public,
|
||||
private: $config
|
||||
}
|
||||
// Export merged config
|
||||
export const config = defu(runtimeConfig.private, runtimeConfig.public)
|
||||
export default config
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { createRenderer } from 'vue-bundle-renderer'
|
||||
import devalue from '@nuxt/devalue'
|
||||
import config from './config'
|
||||
import { runtimeConfig } from './config'
|
||||
// @ts-ignore
|
||||
import htmlTemplate from '#build/views/document.template.js'
|
||||
|
||||
@ -41,10 +41,7 @@ export async function renderMiddleware (req, res) {
|
||||
url,
|
||||
req,
|
||||
res,
|
||||
runtimeConfig: {
|
||||
public: config.public,
|
||||
private: config.private
|
||||
},
|
||||
runtimeConfig,
|
||||
...(req.context || {})
|
||||
}
|
||||
const renderer = await loadRenderer()
|
||||
|
Loading…
Reference in New Issue
Block a user