Skip to content

Commit 50c7833

Browse files
committed
fix(@angular-devkit/build-angular): use valid CSS comment for sourcemaps with Sass in esbuild builder
CSS does not support the single line JS comment (`//`) but rather only the multi-line comment (`/* */`). When generating the sourcemap URL comment with the modern Sass API, the multi-line comment syntax will now be used. This removes the esbuild warnings per Sass file that would have otherwise been generated when stylesheet sourcemaps are enabled for the build.
1 parent bf411b9 commit 50c7833

File tree

1 file changed

+2
-2
lines changed
  • packages/angular_devkit/build_angular/src/builders/browser-esbuild

1 file changed

+2
-2
lines changed

packages/angular_devkit/build_angular/src/builders/browser-esbuild/sass-plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export function createSassPlugin(options: { sourcemap: boolean; loadPaths?: stri
4242

4343
return {
4444
loader: 'css',
45-
contents: css + sourceMapToUrlComment(sourceMap),
45+
contents: `${css}\n${sourceMapToUrlComment(sourceMap)}`,
4646
watchFiles: loadedUrls.map((url) => fileURLToPath(url)),
4747
warnings,
4848
};
@@ -75,5 +75,5 @@ function sourceMapToUrlComment(sourceMap: CompileResult['sourceMap']): string {
7575

7676
const urlSourceMap = Buffer.from(JSON.stringify(sourceMap), 'utf-8').toString('base64');
7777

78-
return `//# sourceMappingURL=data:application/json;charset=utf-8;base64,${urlSourceMap}`;
78+
return `/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${urlSourceMap} */`;
7979
}

0 commit comments

Comments
 (0)