mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(vite): clean up dynamic paths (#4130)
This commit is contained in:
parent
fe8e325541
commit
3ea39e0745
@ -33,6 +33,12 @@ export const RelativeAssetPlugin = function (): Plugin {
|
||||
.replace(assetRE, r => r.replace(/\/__NUXT_BASE__/g, assetBase))
|
||||
.replace(/\/__NUXT_BASE__/g, publicBase)
|
||||
}
|
||||
if (asset.type === 'chunk' && typeof asset.code === 'string') {
|
||||
asset.code = asset.code
|
||||
.replace(/`\$\{(_?_?publicAssetsURL|buildAssetsURL|)\(\)\}([^`]*)`/g, '$1(`$2`)')
|
||||
.replace(/"\/__NUXT_BASE__\/([^"]*)"\.replace\("\/__NUXT_BASE__", ""\)/g, '"$1"')
|
||||
.replace(/'\/__NUXT_BASE__\/([^']*)'\.replace\("\/__NUXT_BASE__", ""\)/g, '"$1"')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import { prepareDevServerEntry } from './vite-node'
|
||||
import { isCSS, isDirectory, readDirRecursively } from './utils'
|
||||
import { bundleRequest } from './dev-bundler'
|
||||
import { writeManifest } from './manifest'
|
||||
import { RelativeAssetPlugin } from './plugins/dynamic-base'
|
||||
|
||||
export async function buildServer (ctx: ViteBuildContext) {
|
||||
const _resolve = id => resolveModule(id, { paths: ctx.nuxt.options.modulesDir })
|
||||
@ -74,6 +75,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
||||
},
|
||||
plugins: [
|
||||
cacheDirPlugin(ctx.nuxt.options.rootDir, 'server'),
|
||||
RelativeAssetPlugin(),
|
||||
vuePlugin(ctx.config.vue),
|
||||
viteJsxPlugin()
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user