fix(nuxt): support usage of std-env in runtime code (#21372)

This commit is contained in:
Daniel Roe 2023-06-05 19:23:38 +01:00 committed by GitHub
parent febf4b807d
commit 05b577e550
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -408,7 +408,10 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
options._modules.push(schemaModule) options._modules.push(schemaModule)
options.modulesDir.push(resolve(options.workspaceDir, 'node_modules')) options.modulesDir.push(resolve(options.workspaceDir, 'node_modules'))
options.modulesDir.push(resolve(pkgDir, 'node_modules')) options.modulesDir.push(resolve(pkgDir, 'node_modules'))
options.build.transpile.push('@nuxt/ui-templates') options.build.transpile.push(
'@nuxt/ui-templates', // this exposes vue SFCs
'std-env' // we need to statically replace process.env when used in runtime code
)
options.alias['vue-demi'] = resolve(options.appDir, 'compat/vue-demi') options.alias['vue-demi'] = resolve(options.appDir, 'compat/vue-demi')
options.alias['@vue/composition-api'] = resolve(options.appDir, 'compat/capi') options.alias['@vue/composition-api'] = resolve(options.appDir, 'compat/capi')
if (options.telemetry !== false && !process.env.NUXT_TELEMETRY_DISABLED) { if (options.telemetry !== false && !process.env.NUXT_TELEMETRY_DISABLED) {

View File

@ -37,6 +37,7 @@ export async function buildClient (ctx: ViteBuildContext) {
devSourcemap: ctx.nuxt.options.sourcemap.client devSourcemap: ctx.nuxt.options.sourcemap.client
}, },
define: { define: {
'process.env.NODE_ENV': JSON.stringify(ctx.config.mode),
'process.server': false, 'process.server': false,
'process.client': true, 'process.client': true,
'module.hot': false 'module.hot': false