From 9d08cdfd1f1d65bc2e34a6a14e970d8631328bc2 Mon Sep 17 00:00:00 2001 From: Daniel Roe Date: Fri, 15 Mar 2024 10:53:31 -0700 Subject: [PATCH] fix(vite): explicitly import `publicAssetsURL` --- packages/vite/src/plugins/public-dirs.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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)))})` } } },