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

feat(v2): add fonts loaders + webpack resolve.roots #4198

Merged
merged 1 commit into from
Feb 9, 2021

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Feb 8, 2021

Motivation

After upgrading css-loader here: #4081

The url(/my/font.ttf) are not resolved by Webpack, while it was not the case before.

Exemple in:

@font-face {
  font-family: "Iran Sans";
  font-style: normal;
  font-weight: 100;
  src: url("/fonts/IRANSans5.5/IRANSansWeb_UltraLight.eot"),
    /* IE9 Compat Modes */
      url("/fonts/IRANSans5.5/IRANSansWeb_UltraLight.eot?#iefix")
      format("embedded-opentype"),
    /* IE6-IE8 */ url("/fonts/IRANSans5.5/IRANSansWeb_UltraLight.woff2")
      format("woff2"),
    /* Super Modern Browsers */
      url("/fonts/IRANSans5.5/IRANSansWeb_UltraLight.woff") format("woff"),
    /* Modern Browsers */ url("/fonts/IRANSans5.5/IRANSansWeb_UltraLight.ttf")
      format("truetype");
} 

The CSS above now fails to build, because /fonts/IRANSans5.5/IRANSansWeb_UltraLight.eot can't be resolved (due to not resolving from the static folder, and also because there's no loader for .eot files.

I think it's not a bad idea to go through the Webpack assets pipeline in such case (as it hash the assets, allowing easier/better caching) so we won't disable this, but need to keep the existing userland CSS retrocompatible.

More context discussed here: webpack-contrib/css-loader#1256

Have you read the Contributing Guidelines on pull requests?

yes

Test Plan

Tested locally using a site using the CSS above:
https://github.com/massoudmaboudi/datagit_v2.docusaurus

After this change, the site can now build again after upgrading Docusaurus while it can't without this change.

@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Feb 8, 2021
@slorber slorber requested a review from lex111 as a code owner February 8, 2021 19:07
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Feb 8, 2021
@netlify
Copy link

netlify bot commented Feb 8, 2021

[V1] Deploy preview success

Built with commit c0e12b5

https://deploy-preview-4198--docusaurus-1.netlify.app

@github-actions
Copy link

github-actions bot commented Feb 8, 2021

Size Change: +13 B (0%)

Total Size: 156 kB

ℹ️ View Unchanged
Filename Size Change
website/build/assets/css/styles.********.css 17.6 kB 0 B
website/build/assets/js/main.********.js 109 kB +14 B (0%)
website/build/blog/2017/12/14/introducing-docusaurus/index.html 21.7 kB 0 B
website/build/docs/introduction/index.html 180 B 0 B
website/build/index.html 6.94 kB -1 B (0%)

compressed-size-action

@netlify
Copy link

netlify bot commented Feb 8, 2021

Deploy preview for docusaurus-2 ready!

Built with commit c0e12b5

https://deploy-preview-4198--docusaurus-2.netlify.app

@github-actions
Copy link

github-actions bot commented Feb 8, 2021

⚡️ Lighthouse report for the changes in this PR:

Category Score
🟠 Performance 74
🟢 Accessibility 96
🟢 Best practices 100
🟢 SEO 100
🟢 PWA 95

Lighthouse ran on https://deploy-preview-4198--docusaurus-2.netlify.app/classic/

@slorber slorber merged commit 2a12869 into master Feb 9, 2021
@lex111 lex111 added this to the v2.0.0-alpha.71 milestone Mar 1, 2021
This was referenced Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants