mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-25 23:22:02 +00:00
fix(vite): use same asset filenames between server and client (#7436)
This commit is contained in:
parent
46240a8c14
commit
d5078168be
@ -8,8 +8,6 @@ import { getPort } from 'get-port-please'
|
||||
import { joinURL, withLeadingSlash, withoutLeadingSlash, withTrailingSlash } from 'ufo'
|
||||
import escapeRE from 'escape-string-regexp'
|
||||
import defu from 'defu'
|
||||
import { sanitizeFilePath } from 'mlly'
|
||||
import { filename } from 'pathe/utils'
|
||||
import type { OutputOptions } from 'rollup'
|
||||
import { cacheDirPlugin } from './plugins/cache-dir'
|
||||
import { wpfs } from './utils/wpfs'
|
||||
@ -80,10 +78,6 @@ export async function buildClient (ctx: ViteBuildContext) {
|
||||
// We want to respect users' own rollup output options
|
||||
clientConfig.build!.rollupOptions = defu(clientConfig.build!.rollupOptions!, {
|
||||
output: {
|
||||
// https://github.com/vitejs/vite/tree/main/packages/vite/src/node/build.ts#L464-L478
|
||||
assetFileNames: ctx.nuxt.options.dev
|
||||
? undefined
|
||||
: chunk => withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, `${sanitizeFilePath(filename(chunk.name!))}.[hash].[ext]`)),
|
||||
chunkFileNames: ctx.nuxt.options.dev ? undefined : withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, '[name].[hash].js')),
|
||||
entryFileNames: ctx.nuxt.options.dev ? 'entry.js' : withoutLeadingSlash(join(ctx.nuxt.options.app.buildAssetsDir, '[name].[hash].js'))
|
||||
} as OutputOptions
|
||||
|
@ -6,6 +6,8 @@ import { logger, isIgnored, resolvePath } from '@nuxt/kit'
|
||||
import type { Options } from '@vitejs/plugin-vue'
|
||||
import replace from '@rollup/plugin-replace'
|
||||
import { sanitizeFilePath } from 'mlly'
|
||||
import { withoutLeadingSlash } from 'ufo'
|
||||
import { filename } from 'pathe/utils'
|
||||
import { buildClient } from './client'
|
||||
import { buildServer } from './server'
|
||||
import virtual from './plugins/virtual'
|
||||
@ -55,7 +57,13 @@ export async function bundle (nuxt: Nuxt) {
|
||||
css: resolveCSSOptions(nuxt),
|
||||
build: {
|
||||
rollupOptions: {
|
||||
output: { sanitizeFileName: sanitizeFilePath }
|
||||
output: {
|
||||
sanitizeFileName: sanitizeFilePath,
|
||||
// https://github.com/vitejs/vite/tree/main/packages/vite/src/node/build.ts#L464-L478
|
||||
assetFileNames: nuxt.options.dev
|
||||
? undefined
|
||||
: chunk => withoutLeadingSlash(join(nuxt.options.app.buildAssetsDir, `${sanitizeFilePath(filename(chunk.name!))}.[hash].[ext]`))
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
exclude: nuxt.options.ignore
|
||||
|
Loading…
Reference in New Issue
Block a user