Skip to content

Commit 87a61aa

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.
1 parent a910ae9 commit 87a61aa

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)