@@ -20,7 +20,7 @@ import { getIndexInputFile, getIndexOutputFile } from '../../utils/webpack-brows
20
20
import { resolveGlobalStyles } from '../../webpack/configs' ;
21
21
import { Schema as BrowserBuilderOptions , SourceMapClass } from '../browser/schema' ;
22
22
import { createCompilerPlugin } from './compiler-plugin' ;
23
- import { bundle , logMessages } from './esbuild' ;
23
+ import { DEFAULT_OUTDIR , bundle , logMessages } from './esbuild' ;
24
24
import { logExperimentalWarnings } from './experimental-warnings' ;
25
25
import { normalizeOptions } from './options' ;
26
26
import { bundleStylesheetText } from './stylesheets' ;
@@ -116,11 +116,13 @@ export async function execute(
116
116
// Entries in the metafile are relative to the `absWorkingDir` option which is set to the workspaceRoot
117
117
const relativeFilePath = path . relative ( workspaceRoot , outputFile . path ) ;
118
118
const entryPoint = result . metafile ?. outputs [ relativeFilePath ] ?. entryPoint ;
119
+
120
+ outputFile . path = path . relative ( DEFAULT_OUTDIR , outputFile . path ) ;
121
+
119
122
if ( entryPoint ) {
120
123
// An entryPoint value indicates an initial file
121
124
initialFiles . push ( {
122
- // Remove leading directory separator
123
- file : outputFile . path . slice ( 1 ) ,
125
+ file : outputFile . path ,
124
126
name : entryPointNameLookup . get ( entryPoint ) ?? '' ,
125
127
extension : path . extname ( outputFile . path ) ,
126
128
} ) ;
@@ -147,7 +149,9 @@ export async function execute(
147
149
! ! options . preserveSymlinks ,
148
150
) ;
149
151
for ( const [ name , files ] of Object . entries ( stylesheetEntrypoints ) ) {
150
- const virtualEntryData = files . map ( ( file ) => `@import '${ file } ';` ) . join ( '\n' ) ;
152
+ const virtualEntryData = files
153
+ . map ( ( file ) => `@import '${ file . replace ( / \\ / g, '/' ) } ';` )
154
+ . join ( '\n' ) ;
151
155
const sheetResult = await bundleStylesheetText (
152
156
virtualEntryData ,
153
157
{ virtualName : `angular:style/global;${ name } ` , resolvePath : workspaceRoot } ,
@@ -172,7 +176,7 @@ export async function execute(
172
176
// The virtual stylesheets will be named `stdin` by esbuild. This must be replaced
173
177
// with the actual name of the global style and the leading directory separator must
174
178
// also be removed to make the path relative.
175
- const sheetPath = sheetResult . path . replace ( 'stdin' , name ) . slice ( 1 ) ;
179
+ const sheetPath = sheetResult . path . replace ( 'stdin' , name ) ;
176
180
outputFiles . push ( createOutputFileFromText ( sheetPath , sheetResult . contents ) ) ;
177
181
if ( sheetResult . map ) {
178
182
outputFiles . push ( createOutputFileFromText ( sheetPath + '.map' , sheetResult . map ) ) ;
@@ -203,10 +207,13 @@ export async function execute(
203
207
optimization : optimizationOptions ,
204
208
crossOrigin : options . crossOrigin ,
205
209
} ) ;
206
- indexHtmlGenerator . readAsset = async function ( path : string ) : Promise < string > {
210
+
211
+ /** Virtual output path to support reading in-memory files. */
212
+ const virtualOutputPath = '/' ;
213
+ indexHtmlGenerator . readAsset = async function ( filePath : string ) : Promise < string > {
207
214
// Remove leading directory separator
208
- path = path . slice ( 1 ) ;
209
- const file = outputFiles . find ( ( file ) => file . path === path ) ;
215
+ const relativefilePath = path . relative ( virtualOutputPath , filePath ) ;
216
+ const file = outputFiles . find ( ( file ) => file . path === relativefilePath ) ;
210
217
if ( file ) {
211
218
return file . text ;
212
219
}
@@ -217,7 +224,7 @@ export async function execute(
217
224
const { content, warnings, errors } = await indexHtmlGenerator . process ( {
218
225
baseHref : options . baseHref ,
219
226
lang : undefined ,
220
- outputPath : '/' , // Virtual output path to support reading in-memory files
227
+ outputPath : virtualOutputPath ,
221
228
files : initialFiles ,
222
229
} ) ;
223
230
@@ -280,7 +287,7 @@ async function bundleCode(
280
287
metafile : true ,
281
288
minify : optimizationOptions . scripts ,
282
289
pure : [ 'forwardRef' ] ,
283
- outdir : '/' ,
290
+ outdir : DEFAULT_OUTDIR ,
284
291
sourcemap : sourcemapOptions . scripts && ( sourcemapOptions . hidden ? 'external' : true ) ,
285
292
splitting : true ,
286
293
tsconfig,
0 commit comments