Skip to content

Commit 00a5b38

Browse files
committed
fix(material/schematics): remove node_modules prefix from prebuilt theme
The Angular CLI supports resolving node modules without the need of specifying `node_modules` directory. This also needed to add support for Yarn PNP which doesn't create a `node_modules` directory. Closes #25242
1 parent 02bf722 commit 00a5b38

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/material/schematics/ng-add/index.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ describe('ng-add schematic', () => {
109109
const workspace = await getWorkspace(tree);
110110
const project = getProjectFromWorkspace(workspace, baseOptions.project);
111111

112-
expectProjectStyleFile(
113-
project,
114-
'./node_modules/@angular/material/prebuilt-themes/indigo-pink.css',
115-
);
112+
expectProjectStyleFile(project, '@angular/material/prebuilt-themes/indigo-pink.css');
116113
});
117114

118115
it('should support adding a custom theme', async () => {
@@ -393,8 +390,7 @@ describe('ng-add schematic', () => {
393390

394391
describe('theme files', () => {
395392
/** Path to the default prebuilt theme file that will be added when running ng-add. */
396-
const defaultPrebuiltThemePath =
397-
'./node_modules/@angular/material/prebuilt-themes/indigo-pink.css';
393+
const defaultPrebuiltThemePath = '@angular/material/prebuilt-themes/indigo-pink.css';
398394

399395
/** Writes a specific style file to the workspace in the given tree */
400396
function writeStyleFileToWorkspace(tree: Tree, stylePath: string) {
@@ -430,7 +426,7 @@ describe('ng-add schematic', () => {
430426
}
431427

432428
it('should replace existing prebuilt theme files', async () => {
433-
const existingThemePath = './node_modules/@angular/material/prebuilt-themes/purple-green.css';
429+
const existingThemePath = '@angular/material/prebuilt-themes/purple-green.css';
434430
writeStyleFileToWorkspace(appTree, existingThemePath);
435431

436432
const tree = await runner

src/material/schematics/ng-add/theming/theming.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,7 @@ async function insertCustomTheme(
109109

110110
/** Insert a pre-built theme into the angular.json file. */
111111
function insertPrebuiltTheme(project: string, theme: string, logger: logging.LoggerApi): Rule {
112-
// Path needs to be always relative to the `package.json` or workspace root.
113-
const themePath = `./node_modules/@angular/material/prebuilt-themes/${theme}.css`;
112+
const themePath = `@angular/material/prebuilt-themes/${theme}.css`;
114113

115114
return chain([
116115
addThemeStyleToTarget(project, 'build', themePath, logger),

0 commit comments

Comments
 (0)