Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REGRESSION][v12.2] Font is no longer loaded #21662

Closed
2 tasks done
hakimio opened this issue Aug 27, 2021 · 17 comments · Fixed by #21681
Closed
2 tasks done

[REGRESSION][v12.2] Font is no longer loaded #21662

hakimio opened this issue Aug 27, 2021 · 17 comments · Fixed by #21681

Comments

@hakimio
Copy link

hakimio commented Aug 27, 2021

🐞 Bug report

Command (mark with an x)

  • build
  • serve

Is this a regression?

Yes, the previous version in which this bug was not present was: 12.1

Description

I have attached a simple demo app which reproduces the issue. Basically following font import in foo-bar.css (included in angular.json styles section) is ignored in v12.2 but works as intended in v12.1:

@import 'https://fonts.googleapis.com/css2?family=Manrope:wght@500;800&display=swap';

🔬 Minimal Reproduction

  • Install dependencies and run ng serve in the demo project provided

🌍 Your Environment


@angular/cli 12.2.3
@angular-devkit/architect    0.1202.3
@angular-devkit/core         12.2.3
@angular-devkit/schematics   12.2.3
@schematics/angular          12.2.3

🐛 Bug demo

import-bug2.zip

@alan-agius4
Copy link
Collaborator

Related to #20906 and #20760

Let’s continue tracking this in #20760

@hakimio
Copy link
Author

hakimio commented Aug 27, 2021

@alan-agius4 this one is reproducable with inlineCriticalCss disabled and it used to work in v12.1.

Try the updated demo to see the issue.

@alan-agius4
Copy link
Collaborator

alan-agius4 commented Aug 27, 2021

I am able to replicate this issue in 12.1, and unable to replicate when inlineCriticalCss is disabled.

During the build you are also getting a related warnings when is inlineCriticalCss is enabled.

Warning: 1 rules skipped due to selector errors:
  800&display=swap); -> Unmatched selector: &display=swap);

Screenshot 2021-08-27 at 13 59 06

@hakimio
Copy link
Author

hakimio commented Aug 27, 2021

Yes, I know about those warnings during production build but this is a different issue which is happening during development build with ng serve as well where optimizations are not applied (AFAIK). Note that the style order in angular.json is important to reproduce the issue:

"styles": [
  "src/styles.scss",
  "src/foo-bar.css"
],

If I use Angular v12.2 fonts are not loaded (check Network -> Fonts to see the requests) and if I switch to v12.1, they are loading.

@alan-agius4
Copy link
Collaborator

I am unable to replicate using the reproduction you provided.
Screenshot 2021-08-27 at 14 59 11

@hakimio
Copy link
Author

hakimio commented Aug 27, 2021

I have uploaded it twice. The first time, I messed it up. Are you testing the one from the second upload import-bug2.zip?

@alan-agius4
Copy link
Collaborator

I am using the latest and I am unable to reproduce. It's also hard to tell what changed without the reproduction.

Ideally, in future it would be great if you could avoid zip files and instead push the minimal reproduction repository to github and link it here.

@hakimio
Copy link
Author

hakimio commented Aug 27, 2021

Just the order of css files in angular.json changed. I tested it again from the zip file and could reproduce the bug. It's strange that it works for you.

@hakimio
Copy link
Author

hakimio commented Aug 31, 2021

@alan-agius4 Sorry to bother you again but can you please test another reproduction when you have some time.
Following is a little bit bigger project but the issue is exactly the same.

Reproduction

  1. Clone ng-v12.2-bug branch in hakimio/ngx-ui-tour git repo:
    https://github.com/hakimio/ngx-ui-tour/tree/ng-v12.2-bug
  2. Install dependencies
    yarn install
  3. Serve the demo app with ng serve
  4. Check the "Network" tab to see if the "Manrope" font is loaded by searching for "Manrope" (browser cache should be disabled)
  5. The search result should be empty and you should see that the font is not applied to the text of the app
  6. However the font should be loaded since it is included the following way:
    angular.json styles section -> node_modules/@taiga-ui/core/styles/taiga-ui-theme.less -> theme/fonts.css -> @import 'https://fonts.googleapis.com/css2?family=Manrope:wght@500;800&display=swap';

Additional Info

If you downgrade Angular to v12.1, you should see that the font is being loaded:

Angular downgrade

Manrope font load

@alan-agius4
Copy link
Collaborator

Look like it's working as expected

Screenshot 2021-08-31 at 10 56 20

@hakimio
Copy link
Author

hakimio commented Aug 31, 2021

@alan-agius4 I can't see from that screenshot if the Manrope font is loaded. Why did you attach that image?

EDIT: did you serve development build or production?

@alan-agius4
Copy link
Collaborator

So indeed the Monorope font is not being loaded. I managed to track down the issue to css-loader, previously it moved absolute @imports to the top of the file but now they are not which causes the @import to become invalid since @import need to appear at the top of the file. https://developer.mozilla.org/en-US/docs/Web/CSS/@import#description

@hakimio
Copy link
Author

hakimio commented Aug 31, 2021

Do you plan to open bug report in css-loader repo? Should angular-cli have some kind of workaround for css-loader bug?

EDIT: Downgrade css-loader maybe?

@alan-agius4
Copy link
Collaborator

Opened an issue webpack-contrib/css-loader#1365, let's see what's their response.

@hakimio
Copy link
Author

hakimio commented Aug 31, 2021

Thank you.

alan-agius4 added a commit that referenced this issue Aug 31, 2021
…to `2.2.1`

Using `css-loader` version 6 exposed a bug in `mini-css-extract-plugin` which doesn't handle `@import` rules order correctly.

See webpack-contrib/css-loader#1365

Closes: #21662
@alan-agius4
Copy link
Collaborator

Closed via #21681

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Oct 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants