mirror of
https://github.com/nuxt/nuxt.git
synced 2025-02-18 06:31:27 +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(assetRE, r => r.replace(/\/__NUXT_BASE__/g, assetBase))
|
||||||
.replace(/\/__NUXT_BASE__/g, publicBase)
|
.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 { isCSS, isDirectory, readDirRecursively } from './utils'
|
||||||
import { bundleRequest } from './dev-bundler'
|
import { bundleRequest } from './dev-bundler'
|
||||||
import { writeManifest } from './manifest'
|
import { writeManifest } from './manifest'
|
||||||
|
import { RelativeAssetPlugin } from './plugins/dynamic-base'
|
||||||
|
|
||||||
export async function buildServer (ctx: ViteBuildContext) {
|
export async function buildServer (ctx: ViteBuildContext) {
|
||||||
const _resolve = id => resolveModule(id, { paths: ctx.nuxt.options.modulesDir })
|
const _resolve = id => resolveModule(id, { paths: ctx.nuxt.options.modulesDir })
|
||||||
@ -74,6 +75,7 @@ export async function buildServer (ctx: ViteBuildContext) {
|
|||||||
},
|
},
|
||||||
plugins: [
|
plugins: [
|
||||||
cacheDirPlugin(ctx.nuxt.options.rootDir, 'server'),
|
cacheDirPlugin(ctx.nuxt.options.rootDir, 'server'),
|
||||||
|
RelativeAssetPlugin(),
|
||||||
vuePlugin(ctx.config.vue),
|
vuePlugin(ctx.config.vue),
|
||||||
viteJsxPlugin()
|
viteJsxPlugin()
|
||||||
]
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user