Skip to content
This repository was archived by the owner on Apr 6, 2023. It is now read-only.

Commit 6b20d9e

Browse files
authored
fix(vite): fix dist dir resolution (#6215)
1 parent 5a042cd commit 6b20d9e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

packages/vite/src/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ import { joinURL, withLeadingSlash, withoutLeadingSlash, withTrailingSlash } fro
99
import escapeRE from 'escape-string-regexp'
1010
import defu from 'defu'
1111
import { cacheDirPlugin } from './plugins/cache-dir'
12-
import { analyzePlugin } from './plugins/analyze'
1312
import { wpfs } from './utils/wpfs'
1413
import type { ViteBuildContext, ViteOptions } from './vite'
1514
import { writeManifest } from './manifest'
1615
import { devStyleSSRPlugin } from './plugins/dev-ssr-css'
17-
import { viteNodePlugin } from './vite-node'
1816

1917
export async function buildClient (ctx: ViteBuildContext) {
2018
const clientConfig: vite.InlineConfig = vite.mergeConfig(ctx.config, {
@@ -58,7 +56,9 @@ export async function buildClient (ctx: ViteBuildContext) {
5856
rootDir: ctx.nuxt.options.rootDir,
5957
buildAssetsURL: joinURL(ctx.nuxt.options.app.baseURL, ctx.nuxt.options.app.buildAssetsDir)
6058
}),
61-
viteNodePlugin(ctx)
59+
ctx.nuxt.options.experimental.viteNode
60+
? await import('./vite-node').then(r => r.viteNodePlugin(ctx))
61+
: undefined
6262
],
6363
appType: 'custom',
6464
server: {
@@ -87,7 +87,7 @@ export async function buildClient (ctx: ViteBuildContext) {
8787

8888
// Add analyze plugin if needed
8989
if (ctx.nuxt.options.build.analyze) {
90-
clientConfig.plugins.push(...analyzePlugin(ctx))
90+
clientConfig.plugins.push(...await import('./plugins/analyze').then(r => r.analyzePlugin(ctx)))
9191
}
9292

9393
await ctx.nuxt.callHook('vite:extendConfig', clientConfig, { isClient: true, isServer: false })

packages/vite/src/dirs.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import { fileURLToPath } from 'node:url'
22
import { dirname, resolve } from 'pathe'
33

4-
export const distDir = dirname(fileURLToPath(import.meta.url))
4+
let _distDir = dirname(fileURLToPath(import.meta.url))
5+
if (_distDir.endsWith('chunks')) { _distDir = dirname(_distDir) }
6+
export const distDir = _distDir
57
export const pkgDir = resolve(distDir, '..')

0 commit comments

Comments
 (0)