File tree 1 file changed +8
-6
lines changed
1 file changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -126,13 +126,15 @@ export function createBuildContext(initialOptions: BuildOptions): UnpluginBuildC
126
126
throw new Error ( 'unplugin/esbuild: addWatchFile outside supported hooks (resolveId, load, transform)' )
127
127
} ,
128
128
emitFile ( emittedFile ) {
129
- // Ensure output directory exists for this.emitFile
130
- if ( initialOptions . outdir && ! fs . existsSync ( initialOptions . outdir ) )
131
- fs . mkdirSync ( initialOptions . outdir , { recursive : true } )
132
-
133
129
const outFileName = emittedFile . fileName || emittedFile . name
134
- if ( initialOptions . outdir && emittedFile . source && outFileName )
135
- fs . writeFileSync ( path . resolve ( initialOptions . outdir , outFileName ) , emittedFile . source )
130
+ if ( initialOptions . outdir && emittedFile . source && outFileName ) {
131
+ const outPath = path . resolve ( initialOptions . outdir , outFileName )
132
+ // Ensure output directory exists for this.emitFile
133
+ const outDir = path . dirname ( outPath )
134
+ if ( ! fs . existsSync ( outDir ) )
135
+ fs . mkdirSync ( outDir , { recursive : true } )
136
+ fs . writeFileSync ( outPath , emittedFile . source )
137
+ }
136
138
} ,
137
139
getWatchFiles ( ) {
138
140
return watchFiles
You can’t perform that action at this time.
0 commit comments