-
Notifications
You must be signed in to change notification settings - Fork 12k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@angular-devkit/build-angular): correctly handle sass imports
Prior to this change nested imports in sass were processed as scss when using the esbuild builder due to an incorrect check. Closes #25338 (cherry picked from commit cc09b70)
- Loading branch information
1 parent
7e8cc32
commit eebb54c
Showing
2 changed files
with
45 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
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,43 @@ | ||
import { | ||
writeMultipleFiles, | ||
deleteFile, | ||
expectFileToMatch, | ||
replaceInFile, | ||
} from '../../../utils/fs'; | ||
import { expectToFail } from '../../../utils/utils'; | ||
import { ng } from '../../../utils/process'; | ||
import { updateJsonFile } from '../../../utils/project'; | ||
|
||
export default async function () { | ||
await writeMultipleFiles({ | ||
'src/styles.sass': ` | ||
@import './imported-styles.sass' | ||
body | ||
background-color: blue | ||
`, | ||
'src/imported-styles.sass': ` | ||
p | ||
background-color: red | ||
`, | ||
'src/app/app.component.sass': ` | ||
.outer | ||
.inner | ||
background: #fff | ||
`, | ||
}); | ||
|
||
await updateJsonFile('angular.json', (workspaceJson) => { | ||
const appArchitect = workspaceJson.projects['test-project'].architect; | ||
appArchitect.build.options.styles = [{ input: 'src/styles.sass' }]; | ||
}); | ||
|
||
await deleteFile('src/app/app.component.css'); | ||
await replaceInFile('src/app/app.component.ts', './app.component.css', './app.component.sass'); | ||
|
||
await ng('build', '--source-map', '--configuration=development'); | ||
|
||
await expectFileToMatch('dist/test-project/styles.css', /body\s*{\s*background-color: blue;\s*}/); | ||
await expectFileToMatch('dist/test-project/styles.css', /p\s*{\s*background-color: red;\s*}/); | ||
await expectToFail(() => expectFileToMatch('dist/test-project/styles.css', '"mappings":""')); | ||
await expectFileToMatch('dist/test-project/main.js', /.outer.*.inner.*background:\s*#[fF]+/); | ||
} |