Skip to content

Commit 4c25185

Browse files
clydindgp1130
authored andcommitted
perf(@angular-devkit/build-angular): avoid extra string creation with no sourcemaps for esbuild sass
When using the experimental esbuild-based browser application builder with Sass stylesheets, an additional string creation for each output stylesheet will now be avoided when sourcemaps are disabled. (cherry picked from commit a910ae9)
1 parent 5fa2901 commit 4c25185

File tree

1 file changed

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

1 file changed

+2
-6
lines changed

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

+2-6
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}\n${sourceMapToUrlComment(sourceMap)}`,
45+
contents: sourceMap ? `${css}\n${sourceMapToUrlComment(sourceMap)}` : css,
4646
watchFiles: loadedUrls.map((url) => fileURLToPath(url)),
4747
warnings,
4848
};
@@ -68,11 +68,7 @@ export function createSassPlugin(options: { sourcemap: boolean; loadPaths?: stri
6868
};
6969
}
7070

71-
function sourceMapToUrlComment(sourceMap: CompileResult['sourceMap']): string {
72-
if (!sourceMap) {
73-
return '';
74-
}
75-
71+
function sourceMapToUrlComment(sourceMap: Exclude<CompileResult['sourceMap'], undefined>): string {
7672
const urlSourceMap = Buffer.from(JSON.stringify(sourceMap), 'utf-8').toString('base64');
7773

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

0 commit comments

Comments
 (0)