Skip to content

Commit

Permalink
fix(@angular-devkit/build-angular): use valid CSS comment for sourcem…
Browse files Browse the repository at this point in the history
…aps 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.
  • Loading branch information
clydin committed Aug 11, 2022
1 parent bf411b9 commit 50c7833
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function createSassPlugin(options: { sourcemap: boolean; loadPaths?: stri

return {
loader: 'css',
contents: css + sourceMapToUrlComment(sourceMap),
contents: `${css}\n${sourceMapToUrlComment(sourceMap)}`,
watchFiles: loadedUrls.map((url) => fileURLToPath(url)),
warnings,
};
Expand Down Expand Up @@ -75,5 +75,5 @@ function sourceMapToUrlComment(sourceMap: CompileResult['sourceMap']): string {

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

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

0 comments on commit 50c7833

Please sign in to comment.