@@ -9,12 +9,10 @@ import { joinURL, withLeadingSlash, withoutLeadingSlash, withTrailingSlash } fro
9
9
import escapeRE from 'escape-string-regexp'
10
10
import defu from 'defu'
11
11
import { cacheDirPlugin } from './plugins/cache-dir'
12
- import { analyzePlugin } from './plugins/analyze'
13
12
import { wpfs } from './utils/wpfs'
14
13
import type { ViteBuildContext , ViteOptions } from './vite'
15
14
import { writeManifest } from './manifest'
16
15
import { devStyleSSRPlugin } from './plugins/dev-ssr-css'
17
- import { viteNodePlugin } from './vite-node'
18
16
19
17
export async function buildClient ( ctx : ViteBuildContext ) {
20
18
const clientConfig : vite . InlineConfig = vite . mergeConfig ( ctx . config , {
@@ -58,7 +56,9 @@ export async function buildClient (ctx: ViteBuildContext) {
58
56
rootDir : ctx . nuxt . options . rootDir ,
59
57
buildAssetsURL : joinURL ( ctx . nuxt . options . app . baseURL , ctx . nuxt . options . app . buildAssetsDir )
60
58
} ) ,
61
- viteNodePlugin ( ctx )
59
+ ctx . nuxt . options . experimental . viteNode
60
+ ? await import ( './vite-node' ) . then ( r => r . viteNodePlugin ( ctx ) )
61
+ : undefined
62
62
] ,
63
63
appType : 'custom' ,
64
64
server : {
@@ -87,7 +87,7 @@ export async function buildClient (ctx: ViteBuildContext) {
87
87
88
88
// Add analyze plugin if needed
89
89
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 ) ) )
91
91
}
92
92
93
93
await ctx . nuxt . callHook ( 'vite:extendConfig' , clientConfig , { isClient : true , isServer : false } )
0 commit comments