mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 15:02:11 +08:00
fix(@angular-devkit/build-angular): ensure empty optimized Sass stylesheets stay empty
When an optimized Sass stylesheet becomes an empty string the AOT Angular host adapter was previously treating this as a falsy value and using the original content of the stylesheet. Empty strings are now considered valid values and will be passed to the AOT compiler as such.
This commit is contained in:
parent
e9a51a37f6
commit
0fa1e3419f
@ -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');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user