Skip to content

Commit

Permalink
perf(@angular-devkit/build-angular): with esbuild builder only load S…
Browse files Browse the repository at this point in the history
…ass 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)
  • Loading branch information
clydin authored and dgp1130 committed Aug 23, 2022
1 parent 4c25185 commit d976405
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -16,12 +16,10 @@ export function createSassPlugin(options: { sourcemap: boolean; loadPaths?: stri
setup(build: PluginBuild): void {
let sass: typeof import('sass');

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

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

0 comments on commit d976405

Please sign in to comment.