Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(@angular-devkit/build-angular): ensure empty optimized Sass stylesheets stay empty #26664

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,26 @@ describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => {
const { result } = await harness.executeOnce();
expect(result?.success).toBeTrue();
});

it('should maintain optimized empty Sass stylesheet when original has content', async () => {
await harness.modifyFile('src/app/app.component.ts', (content) => {
return content.replace('./app.component.css', './app.component.scss');
});
await harness.removeFile('src/app/app.component.css');
await harness.writeFile('src/app/app.component.scss', '@import "variables";');
await harness.writeFile('src/app/_variables.scss', '$value: blue;');

harness.useTarget('build', {
...BASE_OPTIONS,
optimization: {
styles: true,
},
});

const { result } = await harness.executeOnce();
expect(result?.success).toBeTrue();

harness.expectFile('dist/browser/main.js').content.not.toContain('variables');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function createAngularCompilerHost(
context.resourceFile ?? undefined,
);

return result ? { content: result } : null;
return typeof result === 'string' ? { content: result } : null;
};

// Allow the AOT compiler to request the set of changed templates and styles
Expand Down