carbon-components-angular icon indicating copy to clipboard operation
carbon-components-angular copied to clipboard

[BUG] Angular 17 can't resolve path to included IBM Plex fonts

Open Hrothgar32 opened this issue 1 year ago • 5 comments

Detailed description

Hello!

We've been trying to incorporate the Carbon Components package into our Angular 17 project in which we use standalone components, but by following the initial steps in the README, at the moment we try to build/serve our project the compiler throws an error indicating that it cannot resolve the paths to the included IBM Plex fonts.

The issue is reproducible even in older versions of Angular 17, but if we downgrade to Angular 16 the steps work as intended.

image

Angular CLI Version: image

Carbon Components Angular version: "^5.16.4"

Here is the link for a minimal repo on which the issue is reproducible.

Notes

We suspect that there is a slight possibility that the problem may come from upstream: https://github.com/angular/angular-cli/issues/27007 , but we're interested in workarounds if other teams have faced this problem.

Hrothgar32 avatar Feb 01 '24 13:02 Hrothgar32

@Hrothgar32 Thanks for pointing this out, we have to update our documentation to include this:

@use '@carbon/styles/scss/config' with (
	$use-flexbox-grid: true,
	$font-path: '@ibm/plex' // Since Angular doesn't support `~` imports anymore, we can rewrite the path by updating the config
);

Including $font-path: '@ibm/plex in your configuration should resolve this issue.

Akshat55 avatar Feb 01 '24 23:02 Akshat55

Thank you @Akshat55 for the response!

I've tried your configuration and it resolved the compilation issue, however the styles weren't applied when I imported the modules and used the directives. However importing like this:

@use "@carbon/styles" with (
    $font-path: '@ibm/plex'
);

Solved the compilation issue, and the styles were applied as well!

Hrothgar32 avatar Feb 02 '24 07:02 Hrothgar32

Using angular 16, I had to do this

@use '@carbon/styles/scss/config' with (
    // Use flexbox for grid - stick to CSS Grid or Flexbox
    // CSS Grid has become the default grid system in v11
    $use-flexbox-grid: true,
    $font-path: '@carbon/styles/node_modules/@ibm/plex'
);

Katastrophe831 avatar Mar 01 '24 07:03 Katastrophe831

just ran through this issue, it would be nice if the docs were updated

abdelhalimjean avatar Apr 08 '24 10:04 abdelhalimjean

@use '@carbon/styles/scss/config' with (
	$use-flexbox-grid: true,
	$font-path: '@ibm/plex' // Since Angular doesn't support `~` imports anymore, we can rewrite the path by updating the config
);

had same error here please update docs

goerkemballmueller avatar Jul 29 '24 06:07 goerkemballmueller