Skip to content

Commit d976405

Browse files
clydindgp1130
authored andcommitted
perf(@angular-devkit/build-angular): with esbuild builder only load Sass compiler when needed
Previously, the Sass compiler was imported on the start of every build regardless of its usage. The Sass compiler will now only be loaded if a Sass stylesheet is requested. (cherry picked from commit 87a61aa)
1 parent 4c25185 commit d976405

File tree

1 file changed

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

1 file changed

+3
-5
lines changed

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

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ export function createSassPlugin(options: { sourcemap: boolean; loadPaths?: stri
1616
setup(build: PluginBuild): void {
1717
let sass: typeof import('sass');
1818

19-
build.onStart(async () => {
20-
// Lazily load Sass
21-
sass = await import('sass');
22-
});
19+
build.onLoad({ filter: /\.s[ac]ss$/ }, async (args) => {
20+
// Lazily load Sass when a Sass file is found
21+
sass ??= await import('sass');
2322

24-
build.onLoad({ filter: /\.s[ac]ss$/ }, (args) => {
2523
try {
2624
const warnings: PartialMessage[] = [];
2725
// Use sync version as async version is slower.

0 commit comments

Comments
 (0)