diff --git a/packages/nuxt/src/core/nuxt.ts b/packages/nuxt/src/core/nuxt.ts index 16842c0f5f..defc1037e3 100644 --- a/packages/nuxt/src/core/nuxt.ts +++ b/packages/nuxt/src/core/nuxt.ts @@ -408,7 +408,10 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise { options._modules.push(schemaModule) options.modulesDir.push(resolve(options.workspaceDir, '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/composition-api'] = resolve(options.appDir, 'compat/capi') if (options.telemetry !== false && !process.env.NUXT_TELEMETRY_DISABLED) { diff --git a/packages/vite/src/client.ts b/packages/vite/src/client.ts index 0cc57c6352..bcebae2c50 100644 --- a/packages/vite/src/client.ts +++ b/packages/vite/src/client.ts @@ -37,6 +37,7 @@ export async function buildClient (ctx: ViteBuildContext) { devSourcemap: ctx.nuxt.options.sourcemap.client }, define: { + 'process.env.NODE_ENV': JSON.stringify(ctx.config.mode), 'process.server': false, 'process.client': true, 'module.hot': false