This repository was archived by the owner on Apr 6, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed
Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,20 @@ export async function initNitro (nuxt: Nuxt & { _nitro?: Nitro }) {
2424 srcDir : nuxt . options . serverDir ,
2525 dev : nuxt . options . dev ,
2626 buildDir : nuxt . options . buildDir ,
27+ imports : {
28+ imports : [
29+ {
30+ as : '__buildAssetsURL' ,
31+ name : 'buildAssetsURL' ,
32+ from : resolve ( distDir , 'core/runtime/nitro/paths' )
33+ } ,
34+ {
35+ as : '__publicAssetsURL' ,
36+ name : 'publicAssetsURL' ,
37+ from : resolve ( distDir , 'core/runtime/nitro/paths' )
38+ }
39+ ]
40+ } ,
2741 esbuild : {
2842 options : {
2943 exclude : [
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import { writeManifest } from './manifest'
1212
1313export async function buildServer ( ctx : ViteBuildContext ) {
1414 const _resolve = ( id : string ) => resolveModule ( id , { paths : ctx . nuxt . options . modulesDir } )
15+ const helper = ctx . nuxt . options . nitro . imports !== false ? '' : 'globalThis.'
1516 const serverConfig : vite . InlineConfig = vite . mergeConfig ( ctx . config , {
1617 entry : ctx . entry ,
1718 base : ctx . nuxt . options . dev
@@ -24,11 +25,11 @@ export async function buildServer (ctx: ViteBuildContext) {
2425 return { relative : true }
2526 }
2627 if ( type === 'public' ) {
27- return { runtime : `globalThis. __publicAssetsURL(${ JSON . stringify ( filename ) } )` }
28+ return { runtime : `${ helper } __publicAssetsURL(${ JSON . stringify ( filename ) } )` }
2829 }
2930 if ( type === 'asset' ) {
3031 const relativeFilename = filename . replace ( withTrailingSlash ( withoutLeadingSlash ( ctx . nuxt . options . app . buildAssetsDir ) ) , '' )
31- return { runtime : `globalThis. __buildAssetsURL(${ JSON . stringify ( relativeFilename ) } )` }
32+ return { runtime : `${ helper } __buildAssetsURL(${ JSON . stringify ( relativeFilename ) } )` }
3233 }
3334 }
3435 } ,
You can’t perform that action at this time.
0 commit comments