@@ -8,6 +8,9 @@ import { getPort } from 'get-port-please'
8
8
import { joinURL , withLeadingSlash , withoutLeadingSlash , withTrailingSlash } from 'ufo'
9
9
import escapeRE from 'escape-string-regexp'
10
10
import defu from 'defu'
11
+ import { sanitizeFilePath } from 'mlly'
12
+ import { filename } from 'pathe/utils'
13
+ import type { OutputOptions } from 'rollup'
11
14
import { cacheDirPlugin } from './plugins/cache-dir'
12
15
import { wpfs } from './utils/wpfs'
13
16
import type { ViteBuildContext , ViteOptions } from './vite'
@@ -76,14 +79,16 @@ export async function buildClient (ctx: ViteBuildContext) {
76
79
}
77
80
78
81
// We want to respect users' own rollup output options
79
- ctx . config . build ! . rollupOptions = defu ( ctx . config . build ! . rollupOptions ! , {
82
+ clientConfig . build ! . rollupOptions = defu ( clientConfig . build ! . rollupOptions ! , {
80
83
output : {
81
84
// https://github.com/vitejs/vite/tree/main/packages/vite/src/node/build.ts#L464-L478
82
- assetFileNames : ctx . nuxt . options . dev ? undefined : withoutLeadingSlash ( join ( ctx . nuxt . options . app . buildAssetsDir , '[name].[hash].[ext]' ) ) ,
85
+ assetFileNames : ctx . nuxt . options . dev
86
+ ? undefined
87
+ : chunk => withoutLeadingSlash ( join ( ctx . nuxt . options . app . buildAssetsDir , `${ sanitizeFilePath ( filename ( chunk . name ! ) ) } .[hash].[ext]` ) ) ,
83
88
chunkFileNames : ctx . nuxt . options . dev ? undefined : withoutLeadingSlash ( join ( ctx . nuxt . options . app . buildAssetsDir , '[name].[hash].js' ) ) ,
84
89
entryFileNames : ctx . nuxt . options . dev ? 'entry.js' : withoutLeadingSlash ( join ( ctx . nuxt . options . app . buildAssetsDir , '[name].[hash].js' ) )
85
- }
86
- } )
90
+ } as OutputOptions
91
+ } ) as any
87
92
88
93
if ( clientConfig . server && clientConfig . server . hmr !== false ) {
89
94
const hmrPortDefault = 24678 // Vite's default HMR port
0 commit comments