Skip to content

Commit

Permalink
fix(nuxt): support usage of std-env in runtime code (#21372)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Jun 5, 2023
1 parent febf4b8 commit 05b577e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/nuxt/src/core/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,10 @@ export async function loadNuxt (opts: LoadNuxtOptions): Promise<Nuxt> {
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) {
Expand Down
1 change: 1 addition & 0 deletions packages/vite/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 05b577e

Please sign in to comment.