From 5bd03353ac6bb19c983efb7ff015e7aec3ff61d1 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Wed, 24 Aug 2022 20:21:42 -0400 Subject: [PATCH] fix(@angular-devkit/build-angular): correct esbuild builder global stylesheet sourcemap URL The sourcemap URL in the output CSS files for global stylesheets is now correctly updated to reflect the name of the global stylesheet output file and not the internal `stdin` virtual file name. (cherry picked from commit b647d8069fe5c7e597084a89a238cd507f8ef901) --- .../build_angular/src/builders/browser-esbuild/index.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts index 20a8b9a3f5b7..6d8027a660aa 100644 --- a/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts +++ b/packages/angular_devkit/build_angular/src/builders/browser-esbuild/index.ts @@ -386,10 +386,15 @@ async function bundleGlobalStylesheets( // with the actual name of the global style and the leading directory separator must // also be removed to make the path relative. const sheetPath = sheetResult.path.replace('stdin', name); - outputFiles.push(createOutputFileFromText(sheetPath, sheetResult.contents)); + let sheetContents = sheetResult.contents; if (sheetResult.map) { outputFiles.push(createOutputFileFromText(sheetPath + '.map', sheetResult.map)); + sheetContents = sheetContents.replace( + 'sourceMappingURL=stdin.css.map', + `sourceMappingURL=${name}.css.map`, + ); } + outputFiles.push(createOutputFileFromText(sheetPath, sheetContents)); if (!noInjectNames.includes(name)) { initialFiles.push({