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 resolve Sass partial fi…
…les in node packages Prior to this change non relative partial files were not resolved properly. Example we did not try to resolve `@material/button/button` as `@material/button/_button` which caused the compilation to fail.
- Loading branch information
1 parent
5228c23
commit 4fcb0a8
Showing
2 changed files
with
53 additions
and
4 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
31 changes: 31 additions & 0 deletions
31
tests/legacy-cli/e2e/tests/build/styles/scss-partial-resolution.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,31 @@ | ||
import { installPackage } from '../../../utils/packages'; | ||
import { writeMultipleFiles, deleteFile, replaceInFile } from '../../../utils/fs'; | ||
import { ng } from '../../../utils/process'; | ||
import { updateJsonFile } from '../../../utils/project'; | ||
|
||
export default async function () { | ||
// Supports resolving node_modules with are pointing to partial files partial files. | ||
// @material/button/button below points to @material/button/_button.scss | ||
// https://unpkg.com/browse/@material/button@14.0.0/_button.scss | ||
|
||
await installPackage('@material/button@14.0.0'); | ||
|
||
await writeMultipleFiles({ | ||
'src/styles.scss': ` | ||
@use '@material/button/button' as mat; | ||
`, | ||
'src/app/app.component.scss': ` | ||
@use '@material/button/button' as mat; | ||
`, | ||
}); | ||
|
||
await updateJsonFile('angular.json', (workspaceJson) => { | ||
const appArchitect = workspaceJson.projects['test-project'].architect; | ||
appArchitect.build.options.styles = ['src/styles.scss']; | ||
}); | ||
|
||
await deleteFile('src/app/app.component.css'); | ||
await replaceInFile('src/app/app.component.ts', './app.component.css', './app.component.scss'); | ||
|
||
await ng('build', '--configuration=development'); | ||
} |