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