diff --git a/packages/vite/src/plugins/public-dirs.ts b/packages/vite/src/plugins/public-dirs.ts index ea36b90e47..a660cc0837 100644 --- a/packages/vite/src/plugins/public-dirs.ts +++ b/packages/vite/src/plugins/public-dirs.ts @@ -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)))})` } } },