forked from angular/angular-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@angular/build): add
sassOptions
to stylePreprocessorOptions
…
… in application builder This commit introduces the functionality to configure a limited number of options for Sass processing in the Angular application builder. The following options have been added to enhance the Sass integration: - **futureDeprecations**: Specifies features that are scheduled for deprecation. The compiler will treat these as active and emit warnings as necessary. - **fatalDeprecations**: Identifies Sass features that are already deprecated and will cause build failures if used. - **silenceDeprecations**: This option suppresses deprecation warnings for specified versions. Usage example: ```json "architect": { "build": { "builder": "@angular-devkit/build-angular:application", "options": { "outputHashing": "none", "namedChunks": true, "stylePreprocessorOptions": { "sassOptions": { "futureDeprecations": ["color-functions"], "fatalDeprecations": ["color-functions"], "silenceDeprecations": ["1.77.0"] } } } } } ``` For more information about these options, please refer to the Sass documentation: https://sass-lang.com/documentation/js-api/interfaces/options/ Closes angular#28587
- Loading branch information
1 parent
44f8081
commit 46387b2
Showing
7 changed files
with
145 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
packages/angular/build/src/builders/application/tests/options/sass-options_spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.dev/license | ||
*/ | ||
|
||
import { buildApplication } from '../../index'; | ||
import { APPLICATION_BUILDER_INFO, BASE_OPTIONS, describeBuilder } from '../setup'; | ||
import { logging } from '@angular-devkit/core'; | ||
|
||
describeBuilder(buildApplication, APPLICATION_BUILDER_INFO, (harness) => { | ||
describe('Option: "sassOptions"', () => { | ||
it('should cause the build to fail when using `fatalDeprecations` in global styles', async () => { | ||
await harness.writeFile('src/styles.scss', 'p { color: darken(red, 10%) }'); | ||
|
||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
styles: ['src/styles.scss'], | ||
stylePreprocessorOptions: { | ||
sassOptions: { | ||
fatalDeprecations: ['color-functions'], | ||
}, | ||
}, | ||
}); | ||
|
||
const { result, logs } = await harness.executeOnce({ outputLogsOnFailure: false }); | ||
|
||
expect(result?.success).toBeFalse(); | ||
expect(logs).not.toContain( | ||
jasmine.objectContaining<logging.LogEntry>({ | ||
message: jasmine.stringMatching('darken() is deprecated'), | ||
}), | ||
); | ||
}); | ||
|
||
it('should succeed without `fatalDeprecations` despite using deprecated color functions', async () => { | ||
await harness.writeFiles({ | ||
'src/styles.scss': 'p { color: darken(red, 10%) }', | ||
'src/app/app.component.scss': 'p { color: darken(red, 10%) }', | ||
}); | ||
|
||
await harness.modifyFile('src/app/app.component.ts', (content) => { | ||
return content.replace('./app.component.css', 'app.component.scss'); | ||
}); | ||
|
||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
styles: ['src/styles.scss'], | ||
stylePreprocessorOptions: { | ||
sassOptions: {}, | ||
}, | ||
}); | ||
|
||
const { result } = await harness.executeOnce(); | ||
|
||
expect(result?.success).toBeTrue(); | ||
}); | ||
|
||
it('should cause the build to fail when using `fatalDeprecations` in component styles', async () => { | ||
await harness.modifyFile('src/app/app.component.ts', (content) => { | ||
return content.replace('./app.component.css', 'app.component.scss'); | ||
}); | ||
|
||
await harness.writeFile('src/app/app.component.scss', 'p { color: darken(red, 10%) }'); | ||
|
||
harness.useTarget('build', { | ||
...BASE_OPTIONS, | ||
stylePreprocessorOptions: { | ||
sassOptions: { | ||
fatalDeprecations: ['color-functions'], | ||
}, | ||
}, | ||
}); | ||
|
||
const { result, logs } = await harness.executeOnce({ | ||
outputLogsOnFailure: false, | ||
}); | ||
|
||
expect(result?.success).toBeFalse(); | ||
expect(logs).not.toContain( | ||
jasmine.objectContaining<logging.LogEntry>({ | ||
message: jasmine.stringMatching('darken() is deprecated'), | ||
}), | ||
); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters