Skip to content

bug(schematics): ng-add prebuilt styles config isn't compatible with yarn pnp #25242

Closed
@michaelfaith

Description

@michaelfaith

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

The current implementation of ng-add adds an entry to the angular.json styles array for whichever prebuilt style was selected, and that entry is a relative path involving node_modules, which doesn't work with yarn pnp.

Per this discussion, styles added to an application's angular.json work with module resolution, but not with styles exported via package exports, which is the case for the prebuilt styles.

e.g.

"./prebuilt-themes/indigo-pink.css": {
  "style": "./prebuilt-themes/indigo-pink.css"
},

I'm not sure what can be done to adjust this right now, until the module resolution for angular.json will work with package exports, (unless you think adding the style import to the styles.css/scss is preferable. I personally don't think it is). But once it does support exports, I believe the styles path in

function insertPrebuiltTheme(project: string, theme: string, logger: logging.LoggerApi): Rule {
will need to be adjusted to something like "@angular/material/prebuilt-themes/indigo-pink.css"

Expected Behavior

Ng Add should create a configuration that is compatible with yarn pnp

Actual Behavior

It doesn't currently.

Environment

  • Angular: 14.0.5
  • CDK/Material: 14.0.4
  • Browser(s): Chrome
  • Operating System (e.g. Windows, macOS, Ubuntu): Windows

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgentarea: cdk/schematicscdk/schematics is *not* a public API

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions