fix(vite): use buildAssetsURL for dynamic imports (#4844)

This commit is contained in:
Daniel Roe 2022-05-06 11:51:31 +01:00 committed by GitHub
parent 27d67360e4
commit 4079882bd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,8 +81,8 @@ export const DynamicBasePlugin = createUnplugin(function (options: DynamicBasePl
if (id === 'vite/preload-helper') {
// Define vite base path as buildAssetsUrl (i.e. including _nuxt/)
s.prepend('import { buildAssetsDir } from \'#build/paths.mjs\';\n')
s.replace(/const base = ['"]\/__NUXT_BASE__\/['"]/, 'const base = buildAssetsDir()')
s.prepend('import { buildAssetsURL } from \'#build/paths.mjs\';\n')
s.replace(/const base = ['"]\/__NUXT_BASE__\/['"]/, 'const base = buildAssetsURL()')
}
// Sanitize imports