fix(vite): explicitly import publicAssetsURL

This commit is contained in:
Daniel Roe 2024-03-15 10:53:31 -07:00
parent 0cb095f1f9
commit 9d08cdfd1f
No known key found for this signature in database
GPG Key ID: CBC814C393D93268

View File

@ -24,10 +24,9 @@ export const VitePublicDirsPlugin = createUnplugin(() => {
vite: {
load: {
enforce: 'pre',
handler (id, options) {
handler (id) {
if (id.startsWith(PREFIX)) {
const helper = !options?.ssr || nitro.options.imports !== false ? '' : 'globalThis.'
return `export default ${helper}__publicAssetsURL(${JSON.stringify(decodeURIComponent(id.slice(PREFIX.length)))})`
return `import { publicAssetsURL } from '#build/paths.mjs';export default publicAssetsURL(${JSON.stringify(decodeURIComponent(id.slice(PREFIX.length)))})`
}
}
},