Skip to content

Commit

Permalink
fix(vite): explicitly import publicAssetsURL
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed Mar 15, 2024
1 parent 0cb095f commit 9d08cdf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions packages/vite/src/plugins/public-dirs.ts
Expand Up @@ -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)))})`
}
}
},
Expand Down

0 comments on commit 9d08cdf

Please sign in to comment.