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(svgr): create new Docusaurus SVGR plugin #10677

Merged
merged 24 commits into from
Nov 29, 2024
Merged

Conversation

slorber
Copy link
Collaborator

@slorber slorber commented Nov 14, 2024

Motivation

We historically include SVGR in core by default

This works but it's a bit annoying since it doesn't make it easy for configuring it, including SVGO optimizations that cause troubles in some cases:

Since we don't really want core to expose configuration options, let's extract all this logic to a dedicated plugin instead, that allows passing plugin options to configure both SVGR and SVGO.

Breaking change?

For v3 retro compatibility, I'm adding the new SVGR plugin to the classic preset. Since everybody uses the preset (afaik),

I'm not going to consider it a breaking change unless someone complains in which case we'll look for a solution that we could implement in a patch release.

Note: better retro-compatibility is possible to achieve. But it's more complex and probably not worth it. If any user doesn't use the preset, that's super easy to install/use the plugin manually.

Note: we may change our current SVGR/SVGO defaults in another PR, but that will be a breaking change. Tracked in #10679.

Usage

Preset:

export default {
  presets: [
    [
      'classic',
      {
        svgr: {
          svgrConfig: { /* SVGR options here */ }
        } 
      },
    ],
  ],
};

Plugin:

export default {
  plugins: [
    [
      'svgr',
      {
        svgrConfig: { /* SVGR options here */ }
      }
    ]
  ],
}

Note the API is using svgr.svgrConfig on purpose, it's not a mistake. We might add plugin options that are not directly SVGR options in the future but are more related to the SVGR + Webpack (loader) integration. Or options that decide whether or not to merge the provided config into the default one.

Customizing SVGO

Provide custom SVGO options this way:

export default {
  presets: [
    [
      'classic',
      {
        svgr: {
          svgrConfig: { svgoConfig: { } }
        } 
      },
    ],
  ],
};

If you want to use a custom svgo.config.js file you can use svgoConfig: undefined. When not passing any explicit SVGO config options (which we do by default), the SVGO config file will be used.

Test Plan

CI + Argos

Test links

Pages with SVGs:

Docs:

Configuration Without custom .svgo.config.js With custom .svgo.config.js
Image CleanShot at 17:05 CleanShot at 17:06

Related issues/PRs

See:

@slorber slorber requested a review from Josh-Cena as a code owner November 14, 2024 15:36
@slorber slorber added the pr: new feature This PR adds a new API or behavior. label Nov 14, 2024
@facebook-github-bot facebook-github-bot added the CLA Signed Signed Facebook CLA label Nov 14, 2024
@slorber slorber marked this pull request as draft November 14, 2024 15:36
@slorber slorber added the Argos Add this label to run UI visual regression tests. See argos.yml GH action. label Nov 14, 2024
Copy link

netlify bot commented Nov 14, 2024

[V2]

Name Link
🔨 Latest commit 1f8f6e3
🔍 Latest deploy log https://app.netlify.com/sites/docusaurus-2/deploys/6749e62ceb085c00086158a5
😎 Deploy Preview https://deploy-preview-10677--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

github-actions bot commented Nov 14, 2024

Size Change: +52 kB (+0.46%)

Total Size: 11.3 MB

Filename Size Change
website/.docusaurus/docusaurus.config.mjs 28 kB +56 B (+0.2%)
website/.docusaurus/globalData.json 30.6 kB +174 B (+0.57%)
website/.docusaurus/registry.js 158 kB +442 B (+0.28%)
website/.docusaurus/routes.js 75.6 kB +372 B (+0.49%)
website/.docusaurus/routesChunkNames.json 83.7 kB +248 B (+0.3%)
website/.docusaurus/site-metadata.json 2.3 kB +130 B (+5.99%) 🔍
website/build/assets/js/main.********.js 644 kB +861 B (+0.13%)
website/build/assets/js/runtime~main.********.js 36.6 kB +106 B (+0.29%)
website/build/docs/api/plugins.html 30.6 kB +487 B (+1.62%)
website/build/docs/api/plugins/@docusaurus/plugin-client-redirects.html 59.9 kB +203 B (+0.34%)
website/build/docs/api/plugins/@docusaurus/plugin-content-blog.html 189 kB +203 B (+0.11%)
website/build/docs/api/plugins/@docusaurus/plugin-content-docs.html 194 kB +194 B (+0.1%)
website/build/docs/api/plugins/@docusaurus/plugin-content-pages.html 74.4 kB +190 B (+0.26%)
website/build/docs/api/plugins/@docusaurus/plugin-debug.html 48.4 kB +190 B (+0.39%)
website/build/docs/api/plugins/@docusaurus/plugin-google-analytics.html 49.3 kB +193 B (+0.39%)
website/build/docs/api/plugins/@docusaurus/plugin-google-gtag.html 48.9 kB +186 B (+0.38%)
website/build/docs/api/plugins/@docusaurus/plugin-google-tag-manager.html 47.7 kB +182 B (+0.38%)
website/build/docs/api/plugins/@docusaurus/plugin-ideal-image.html 48.8 kB +194 B (+0.4%)
website/build/docs/api/plugins/@docusaurus/plugin-pwa.html 117 kB +194 B (+0.17%)
website/build/docs/api/plugins/@docusaurus/plugin-rsdoctor.html 40 kB +162 B (+0.41%)
website/build/docs/api/plugins/@docusaurus/plugin-sitemap.html 65.7 kB +196 B (+0.3%)
website/build/docs/api/plugins/@docusaurus/plugin-vercel-analytics.html 40.3 kB +202 B (+0.5%)
website/build/docs/using-plugins.html 111 kB +853 B (+0.77%)
website/build/docs/api/plugins/@docusaurus/plugin-svgr.html 45.5 kB +45.5 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/codeTranslations.json 2 B 0 B
website/.docusaurus/i18n.json 930 B 0 B
website/build/assets/css/styles.********.css 120 kB 0 B
website/build/blog.html 58.3 kB 0 B
website/build/blog/2017/12/14/introducing-docusaurus.html 72.4 kB 0 B
website/build/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus.html 45.3 kB +12 B (+0.03%)
website/build/blog/2018/09/11/Towards-Docusaurus-2.html 49.6 kB 0 B
website/build/blog/2018/12/14/Happy-First-Birthday-Slash.html 28.8 kB 0 B
website/build/blog/2019/12/30/docusaurus-2019-recap.html 37.7 kB -1 B (0%)
website/build/blog/2020/01/07/tribute-to-endi.html 32.2 kB 0 B
website/build/blog/2021/01/19/docusaurus-2020-recap.html 46.7 kB 0 B
website/build/blog/2021/03/09/releasing-docusaurus-i18n.html 43 kB -1 B (0%)
website/build/blog/2021/05/12/announcing-docusaurus-two-beta.html 45.3 kB 0 B
website/build/blog/2021/11/21/algolia-docsearch-migration.html 50.4 kB +12 B (+0.02%)
website/build/blog/2022/01/24/docusaurus-2021-recap.html 42.5 kB 0 B
website/build/blog/2022/08/01/announcing-docusaurus-2.0.html 134 kB 0 B
website/build/blog/2022/09/01/docusaurus-2.1.html 48.3 kB -1 B (0%)
website/build/blog/archive.html 23.2 kB 0 B
website/build/blog/authors.html 44 kB 0 B
website/build/blog/authors/j-marcey.html 62 kB 0 B
website/build/blog/authors/josh-cena.html 40.8 kB 0 B
website/build/blog/authors/lex-111.html 47.7 kB 0 B
website/build/blog/authors/slorber.html 58.2 kB 0 B
website/build/blog/authors/slorber/authors/2.html 61.9 kB 0 B
website/build/blog/authors/slorber/authors/3.html 70.5 kB 0 B
website/build/blog/authors/slorber/authors/4.html 51.4 kB 0 B
website/build/blog/authors/yangshun.html 55 kB 0 B
website/build/blog/authors/zpao.html 41.2 kB 0 B
website/build/blog/page/2.html 62.8 kB 0 B
website/build/blog/page/3.html 64.7 kB 0 B
website/build/blog/page/4.html 66.5 kB 0 B
website/build/blog/page/5.html 45.2 kB 0 B
website/build/blog/preparing-your-site-for-docusaurus-v3.html 133 kB +4 B (0%)
website/build/blog/releases/2.2.html 47.2 kB 0 B
website/build/blog/releases/2.3.html 58 kB 0 B
website/build/blog/releases/2.4.html 62.3 kB 0 B
website/build/blog/releases/3.0.html 107 kB +12 B (+0.01%)
website/build/blog/releases/3.1.html 49.7 kB +1 B (0%)
website/build/blog/releases/3.2.html 46.4 kB 0 B
website/build/blog/releases/3.3.html 53 kB 0 B
website/build/blog/releases/3.4.html 53.2 kB +7 B (+0.01%)
website/build/blog/releases/3.5.html 55.6 kB +1 B (0%)
website/build/blog/releases/3.6.html 75.3 kB +1 B (0%)
website/build/blog/tags.html 26.8 kB 0 B
website/build/blog/upgrading-frontend-dependencies-with-confidence-using-visual-regression-testing.html 123 kB 0 B
website/build/docs.html 47.1 kB 0 B
website/build/docs/advanced.html 29.4 kB 0 B
website/build/docs/advanced/architecture.html 28.9 kB +4 B (+0.01%)
website/build/docs/advanced/client.html 72.7 kB 0 B
website/build/docs/advanced/plugins.html 56 kB 0 B
website/build/docs/advanced/routing.html 70.8 kB +8 B (+0.01%)
website/build/docs/advanced/ssg.html 77.8 kB 0 B
website/build/docs/api/docusaurus-config.html 197 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin.html 45.7 kB +4 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-html-links.html 36 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-untranslated-text.html 35 kB 0 B
website/build/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading.html 36.3 kB +4 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages.html 39.8 kB 0 B
website/build/docs/api/misc/@docusaurus/logger.html 37.9 kB 0 B
website/build/docs/api/misc/create-docusaurus.html 33.1 kB 0 B
website/build/docs/api/plugin-methods.html 64.6 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/extend-infrastructure.html 60.3 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/i18n-lifecycles.html 58.1 kB +4 B (+0.01%)
website/build/docs/api/plugin-methods/lifecycle-apis.html 164 kB 0 B
website/build/docs/api/plugin-methods/static-methods.html 44.4 kB +4 B (+0.01%)
website/build/docs/api/themes.html 28.7 kB 0 B
website/build/docs/api/themes/@docusaurus/theme-classic.html 44 kB +4 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-live-codeblock.html 36.6 kB +4 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-mermaid.html 35.5 kB +4 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-search-algolia.html 32.8 kB 0 B
website/build/docs/api/themes/configuration.html 243 kB 0 B
website/build/docs/blog.html 211 kB +6 B (0%)
website/build/docs/browser-support.html 48.4 kB 0 B
website/build/docs/category/getting-started.html 26.7 kB 0 B
website/build/docs/category/guides.html 34.5 kB 0 B
website/build/docs/cli.html 60 kB 0 B
website/build/docs/configuration.html 98.7 kB +7 B (+0.01%)
website/build/docs/create-doc.html 62.3 kB +12 B (+0.02%)
website/build/docs/creating-pages.html 56.4 kB +1 B (0%)
website/build/docs/deployment.html 203 kB +8 B (0%)
website/build/docs/docs-introduction.html 51 kB 0 B
website/build/docs/docs-multi-instance.html 75 kB +4 B (+0.01%)
website/build/docs/docusaurus-core.html 236 kB 0 B
website/build/docs/guides/whats-next.html 30.9 kB 0 B
website/build/docs/i18n/crowdin.html 145 kB +12 B (+0.01%)
website/build/docs/i18n/git.html 78.8 kB +4 B (+0.01%)
website/build/docs/i18n/introduction.html 48.3 kB 0 B
website/build/docs/i18n/tutorial.html 164 kB +13 B (+0.01%)
website/build/docs/installation.html 70.7 kB +5 B (+0.01%)
website/build/docs/introduction/index.html 280 B 0 B
website/build/docs/markdown-features.html 79.9 kB 0 B
website/build/docs/markdown-features/admonitions.html 113 kB +4 B (0%)
website/build/docs/markdown-features/assets.html 89.2 kB +2 B (0%)
website/build/docs/markdown-features/code-blocks.html 235 kB +4 B (0%)
website/build/docs/markdown-features/diagrams.html 53.1 kB +14 B (+0.03%)
website/build/docs/markdown-features/head-metadata.html 50.1 kB 0 B
website/build/docs/markdown-features/links.html 40.8 kB 0 B
website/build/docs/markdown-features/math-equations.html 90.5 kB +11 B (+0.01%)
website/build/docs/markdown-features/plugins.html 96.7 kB +8 B (+0.01%)
website/build/docs/markdown-features/react.html 138 kB 0 B
website/build/docs/markdown-features/tabs.html 142 kB 0 B
website/build/docs/markdown-features/toc.html 84.8 kB +4 B (0%)
website/build/docs/migration.html 40.7 kB +4 B (+0.01%)
website/build/docs/migration/v2.html 39.2 kB 0 B
website/build/docs/migration/v2/automated.html 40.4 kB 0 B
website/build/docs/migration/v2/manual.html 198 kB 0 B
website/build/docs/migration/v2/translated-sites.html 50.3 kB 0 B
website/build/docs/migration/v2/versioned-sites.html 64.3 kB +8 B (+0.01%)
website/build/docs/migration/v3.html 209 kB +1 B (0%)
website/build/docs/playground.html 30.7 kB 0 B
website/build/docs/resources/index.html 325 B 0 B
website/build/docs/search.html 116 kB +1 B (0%)
website/build/docs/seo.html 88.7 kB +13 B (+0.01%)
website/build/docs/sidebar.html 131 kB 0 B
website/build/docs/sidebar/autogenerated.html 150 kB +13 B (+0.01%)
website/build/docs/sidebar/items.html 180 kB 0 B
website/build/docs/sidebar/multiple-sidebars.html 63.7 kB +4 B (+0.01%)
website/build/docs/static-assets.html 53.5 kB +4 B (+0.01%)
website/build/docs/styling-layout.html 135 kB +1 B (0%)
website/build/docs/support/index.html 319 B 0 B
website/build/docs/swizzling.html 115 kB +14 B (+0.01%)
website/build/docs/team/index.html 310 B 0 B
website/build/docs/typescript-support.html 62.3 kB 0 B
website/build/docs/versioning.html 83.1 kB +13 B (+0.02%)
website/build/index.html 35.8 kB 0 B

compressed-size-action::DOCUSAURUS_INFRA_FASTER

Copy link

github-actions bot commented Nov 14, 2024

⚡️ Lighthouse report for the deploy preview of this PR

URL Performance Accessibility Best Practices SEO Report
/ 🟠 73 🟢 98 🟢 96 🟢 100 Report
/docs/installation 🟠 58 🟢 97 🟢 100 🟢 100 Report
/docs/category/getting-started 🟠 75 🟢 100 🟢 100 🟠 86 Report
/blog 🟠 63 🟢 96 🟢 100 🟠 86 Report
/blog/preparing-your-site-for-docusaurus-v3 🔴 49 🟢 92 🟢 100 🟢 100 Report
/blog/tags/release 🟠 66 🟢 96 🟢 100 🟠 86 Report
/blog/tags 🟠 75 🟢 100 🟢 100 🟠 86 Report

Copy link

argos-ci bot commented Nov 14, 2024

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ⚠️ Changes detected (Review) 16 changed, 2 added Dec 31, 2024, 11:12 PM

Copy link

github-actions bot commented Nov 14, 2024

Size Change: +54.8 kB (+0.47%)

Total Size: 11.7 MB

Filename Size Change
website/.docusaurus/docusaurus.config.mjs 28 kB +56 B (+0.2%)
website/.docusaurus/globalData.json 30.6 kB +174 B (+0.57%)
website/.docusaurus/registry.js 158 kB +442 B (+0.28%)
website/.docusaurus/routes.js 75.6 kB +372 B (+0.49%)
website/.docusaurus/routesChunkNames.json 83.7 kB +248 B (+0.3%)
website/.docusaurus/site-metadata.json 2.3 kB +130 B (+5.99%) 🔍
website/build/assets/js/main.********.js 641 kB +828 B (+0.13%)
website/build/assets/js/runtime~main.********.js 35.9 kB +105 B (+0.29%)
website/build/docs/api/plugins.html 32.4 kB +505 B (+1.58%)
website/build/docs/api/plugins/@docusaurus/plugin-client-redirects.html 63 kB +215 B (+0.34%)
website/build/docs/api/plugins/@docusaurus/plugin-content-blog.html 198 kB +215 B (+0.11%)
website/build/docs/api/plugins/@docusaurus/plugin-content-docs.html 203 kB +206 B (+0.1%)
website/build/docs/api/plugins/@docusaurus/plugin-content-pages.html 78.4 kB +202 B (+0.26%)
website/build/docs/api/plugins/@docusaurus/plugin-debug.html 50.9 kB +202 B (+0.4%)
website/build/docs/api/plugins/@docusaurus/plugin-google-analytics.html 51.9 kB +205 B (+0.4%)
website/build/docs/api/plugins/@docusaurus/plugin-google-gtag.html 51.4 kB +198 B (+0.39%)
website/build/docs/api/plugins/@docusaurus/plugin-google-tag-manager.html 50.2 kB +194 B (+0.39%)
website/build/docs/api/plugins/@docusaurus/plugin-ideal-image.html 51.5 kB +206 B (+0.4%)
website/build/docs/api/plugins/@docusaurus/plugin-pwa.html 122 kB +206 B (+0.17%)
website/build/docs/api/plugins/@docusaurus/plugin-rsdoctor.html 42.3 kB +174 B (+0.41%)
website/build/docs/api/plugins/@docusaurus/plugin-sitemap.html 68.9 kB +208 B (+0.3%)
website/build/docs/api/plugins/@docusaurus/plugin-vercel-analytics.html 42.6 kB +214 B (+0.5%)
website/build/docs/using-plugins.html 116 kB +876 B (+0.76%)
website/build/docs/api/plugins/@docusaurus/plugin-svgr.html 48 kB +48 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size Change
website/.docusaurus/codeTranslations.json 2 B 0 B
website/.docusaurus/i18n.json 930 B 0 B
website/build/assets/css/styles.********.css 114 kB 0 B
website/build/blog.html 61.6 kB +1 B (0%)
website/build/blog/2017/12/14/introducing-docusaurus.html 74.8 kB +1 B (0%)
website/build/blog/2018/04/30/How-I-Converted-Profilo-To-Docusaurus.html 47.5 kB +13 B (+0.03%)
website/build/blog/2018/09/11/Towards-Docusaurus-2.html 51.8 kB +1 B (0%)
website/build/blog/2018/12/14/Happy-First-Birthday-Slash.html 30.5 kB +1 B (0%)
website/build/blog/2019/12/30/docusaurus-2019-recap.html 39.7 kB 0 B
website/build/blog/2020/01/07/tribute-to-endi.html 34.1 kB +1 B (0%)
website/build/blog/2021/01/19/docusaurus-2020-recap.html 49 kB +1 B (0%)
website/build/blog/2021/03/09/releasing-docusaurus-i18n.html 45.3 kB 0 B
website/build/blog/2021/05/12/announcing-docusaurus-two-beta.html 47.6 kB +1 B (0%)
website/build/blog/2021/11/21/algolia-docsearch-migration.html 53.1 kB +13 B (+0.02%)
website/build/blog/2022/01/24/docusaurus-2021-recap.html 44.6 kB +1 B (0%)
website/build/blog/2022/08/01/announcing-docusaurus-2.0.html 139 kB +1 B (0%)
website/build/blog/2022/09/01/docusaurus-2.1.html 51 kB 0 B
website/build/blog/archive.html 24.8 kB +1 B (0%)
website/build/blog/authors.html 46.6 kB +1 B (0%)
website/build/blog/authors/j-marcey.html 65.1 kB +1 B (0%)
website/build/blog/authors/josh-cena.html 43.1 kB +1 B (0%)
website/build/blog/authors/lex-111.html 50.4 kB +1 B (0%)
website/build/blog/authors/slorber.html 61.8 kB +1 B (0%)
website/build/blog/authors/slorber/authors/2.html 65.5 kB +1 B (0%)
website/build/blog/authors/slorber/authors/3.html 74.6 kB +1 B (0%)
website/build/blog/authors/slorber/authors/4.html 54.4 kB +1 B (0%)
website/build/blog/authors/yangshun.html 57.9 kB +1 B (0%)
website/build/blog/authors/zpao.html 43.6 kB +1 B (0%)
website/build/blog/page/2.html 66.1 kB +1 B (0%)
website/build/blog/page/3.html 68.1 kB +1 B (0%)
website/build/blog/page/4.html 69.8 kB +1 B (0%)
website/build/blog/page/5.html 47.5 kB +1 B (0%)
website/build/blog/preparing-your-site-for-docusaurus-v3.html 138 kB 0 B
website/build/blog/releases/2.2.html 49.7 kB +1 B (0%)
website/build/blog/releases/2.3.html 60.9 kB +1 B (0%)
website/build/blog/releases/2.4.html 65.4 kB +1 B (0%)
website/build/blog/releases/3.0.html 112 kB +13 B (+0.01%)
website/build/blog/releases/3.1.html 52.1 kB +2 B (0%)
website/build/blog/releases/3.2.html 48.9 kB +1 B (0%)
website/build/blog/releases/3.3.html 55.6 kB +1 B (0%)
website/build/blog/releases/3.4.html 56 kB +8 B (+0.01%)
website/build/blog/releases/3.5.html 58.4 kB +2 B (0%)
website/build/blog/releases/3.6.html 78.9 kB +2 B (0%)
website/build/blog/tags.html 28.7 kB +1 B (0%)
website/build/blog/upgrading-frontend-dependencies-with-confidence-using-visual-regression-testing.html 128 kB +1 B (0%)
website/build/docs.html 49.2 kB +1 B (0%)
website/build/docs/advanced.html 31.1 kB +1 B (0%)
website/build/docs/advanced/architecture.html 30.7 kB +5 B (+0.02%)
website/build/docs/advanced/client.html 76 kB +1 B (0%)
website/build/docs/advanced/plugins.html 58.6 kB +1 B (0%)
website/build/docs/advanced/routing.html 73.9 kB +9 B (+0.01%)
website/build/docs/advanced/ssg.html 81.5 kB +1 B (0%)
website/build/docs/api/docusaurus-config.html 206 kB +1 B (0%)
website/build/docs/api/misc/@docusaurus/eslint-plugin.html 48.3 kB +5 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-html-links.html 38.1 kB +1 B (0%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/no-untranslated-text.html 37 kB +1 B (0%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/prefer-docusaurus-heading.html 38.3 kB +5 B (+0.01%)
website/build/docs/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages.html 42 kB +1 B (0%)
website/build/docs/api/misc/@docusaurus/logger.html 39.8 kB +1 B (0%)
website/build/docs/api/misc/create-docusaurus.html 34.9 kB +1 B (0%)
website/build/docs/api/plugin-methods.html 67.4 kB +5 B (+0.01%)
website/build/docs/api/plugin-methods/extend-infrastructure.html 63 kB +5 B (+0.01%)
website/build/docs/api/plugin-methods/i18n-lifecycles.html 60.7 kB +5 B (+0.01%)
website/build/docs/api/plugin-methods/lifecycle-apis.html 170 kB +1 B (0%)
website/build/docs/api/plugin-methods/static-methods.html 46.6 kB +5 B (+0.01%)
website/build/docs/api/themes.html 30.4 kB +1 B (0%)
website/build/docs/api/themes/@docusaurus/theme-classic.html 46.4 kB +5 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-live-codeblock.html 38.7 kB +5 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-mermaid.html 37.5 kB +5 B (+0.01%)
website/build/docs/api/themes/@docusaurus/theme-search-algolia.html 34.7 kB +1 B (0%)
website/build/docs/api/themes/configuration.html 256 kB +1 B (0%)
website/build/docs/blog.html 219 kB +7 B (0%)
website/build/docs/browser-support.html 51 kB +1 B (0%)
website/build/docs/category/getting-started.html 28.3 kB +1 B (0%)
website/build/docs/category/guides.html 36.4 kB +1 B (0%)
website/build/docs/cli.html 63.8 kB +1 B (0%)
website/build/docs/configuration.html 103 kB +8 B (+0.01%)
website/build/docs/create-doc.html 65.3 kB +13 B (+0.02%)
website/build/docs/creating-pages.html 59.1 kB +2 B (0%)
website/build/docs/deployment.html 211 kB +9 B (0%)
website/build/docs/docs-introduction.html 53.6 kB +1 B (0%)
website/build/docs/docs-multi-instance.html 78.7 kB +5 B (+0.01%)
website/build/docs/docusaurus-core.html 245 kB +1 B (0%)
website/build/docs/guides/whats-next.html 32.8 kB +1 B (0%)
website/build/docs/i18n/crowdin.html 151 kB +13 B (+0.01%)
website/build/docs/i18n/git.html 82.7 kB +5 B (+0.01%)
website/build/docs/i18n/introduction.html 50.8 kB +1 B (0%)
website/build/docs/i18n/tutorial.html 171 kB +14 B (+0.01%)
website/build/docs/installation.html 74.2 kB +6 B (+0.01%)
website/build/docs/introduction/index.html 280 B 0 B
website/build/docs/markdown-features.html 83.2 kB +1 B (0%)
website/build/docs/markdown-features/admonitions.html 119 kB +5 B (0%)
website/build/docs/markdown-features/assets.html 93.5 kB +3 B (0%)
website/build/docs/markdown-features/code-blocks.html 245 kB +5 B (0%)
website/build/docs/markdown-features/diagrams.html 56 kB +15 B (+0.03%)
website/build/docs/markdown-features/head-metadata.html 52.8 kB +1 B (0%)
website/build/docs/markdown-features/links.html 43.1 kB +1 B (0%)
website/build/docs/markdown-features/math-equations.html 95.4 kB +12 B (+0.01%)
website/build/docs/markdown-features/plugins.html 101 kB +9 B (+0.01%)
website/build/docs/markdown-features/react.html 144 kB +1 B (0%)
website/build/docs/markdown-features/tabs.html 148 kB +1 B (0%)
website/build/docs/markdown-features/toc.html 88.8 kB +5 B (+0.01%)
website/build/docs/migration.html 43.1 kB 0 B
website/build/docs/migration/v2.html 41.3 kB +1 B (0%)
website/build/docs/migration/v2/automated.html 42.6 kB +1 B (0%)
website/build/docs/migration/v2/manual.html 207 kB +1 B (0%)
website/build/docs/migration/v2/translated-sites.html 52.8 kB +1 B (0%)
website/build/docs/migration/v2/versioned-sites.html 67.3 kB +9 B (+0.01%)
website/build/docs/migration/v3.html 218 kB +2 B (0%)
website/build/docs/playground.html 32.5 kB +1 B (0%)
website/build/docs/resources/index.html 325 B 0 B
website/build/docs/search.html 121 kB +2 B (0%)
website/build/docs/seo.html 93 kB +14 B (+0.02%)
website/build/docs/sidebar.html 137 kB +1 B (0%)
website/build/docs/sidebar/autogenerated.html 156 kB +14 B (+0.01%)
website/build/docs/sidebar/items.html 188 kB +1 B (0%)
website/build/docs/sidebar/multiple-sidebars.html 67.1 kB +5 B (+0.01%)
website/build/docs/static-assets.html 56.3 kB +5 B (+0.01%)
website/build/docs/styling-layout.html 141 kB +2 B (0%)
website/build/docs/support/index.html 319 B 0 B
website/build/docs/swizzling.html 120 kB +15 B (+0.01%)
website/build/docs/team/index.html 310 B 0 B
website/build/docs/typescript-support.html 65.4 kB +1 B (0%)
website/build/docs/versioning.html 87.1 kB +14 B (+0.02%)
website/build/index.html 37.7 kB +1 B (0%)

compressed-size-action::DOCUSAURUS_INFRA_SLOWER

@slorber
Copy link
Collaborator Author

slorber commented Nov 14, 2024

I'm not going to merge it right now because I'd like to do another patch release for v3.6

@slorber slorber added this to the 3.x milestone Nov 18, 2024
@slorber slorber merged commit df6f53a into main Nov 29, 2024
39 checks passed
@slorber slorber deleted the slorber/plugin-svgr branch November 29, 2024 16:26
@CMCDragonkai
Copy link

CMCDragonkai commented Jan 6, 2025

Did this feature mean that referencing something.svg in the custom.css now break because webpack complains about not being able to load the SVG file?

For v3 retro compatibility, I'm adding the new SVGR plugin to the classic preset. Since everybody uses the preset (afaik),

We weren't lol.

@slorber
Copy link
Collaborator Author

slorber commented Jan 6, 2025

@CMCDragonkai so what I understand is that you are trying to upgrade this site Polykey-Docs to Docusaurus v3.7, and see a different behavior right?

Indeed you are not using the preset, curious to understand why?
https://github.com/MatrixAI/Polykey-Docs/blob/staging/docusaurus.config.ts

Although I agree, I think the retro-compatibility is not good enough and I broke some use-cases in v3.7. I'll try to figure out how to fix it.

@slorber
Copy link
Collaborator Author

slorber commented Jan 6, 2025

As far as I understand the error comes from using SVGs in font declarations:

@font-face {
  font-family: "Open Sans";
  src: url("/fonts/OpenSans-Semibold-webfont.eot");
  src: url("/fonts/OpenSans-Semibold-webfont.eot?#iefix")
      format("embedded-opentype"),
    url("/fonts/OpenSans-Semibold-webfont.woff") format("woff"),
    url("/fonts/OpenSans-Semibold-webfont.ttf") format("truetype"),
    url("/fonts/OpenSans-Semibold-webfont.svg#open_sanssemibold") format("svg");
  font-weight: 600;
  font-style: normal;
}

It's surprising that CSS loader tries to require those assets, I think I reported a bug in the past (edit, found it: webpack-contrib/css-loader#1256)

But still a thing we supported before, so I'll restore that behavior in #10820. A fix will be in v3.7.1.

@CMCDragonkai
Copy link

CMCDragonkai commented Jan 6, 2025

We were loading SVGs just with a CSS background image.

:root {
  --custom-navbar-search-input-icon: url('/static/images/Search.svg');
}

And we got that build error.

We were scratching our heads, so we compared versions and discovered that docusaurus had changed their underlying version - which to me this is a breaking change...

We don't use the preset because we have a custom theme, so we loaded individual plugins as needed.

We fixed it by loading the plugin that you introduced directly into our docusaurus configuration, and it worked.

Sometimes we also make use of assets that docusaurus's existing webpack configuration doesn't support, so we customise loader plugin too:

/**
 * Process additional extensions under the static assets
 */
const pluginLoaders = () => {
  return {
    name: 'custom-loaders',
    configureWebpack(_config, isServer) {
      return {
        module: {
          rules: [
            {
              test: /\.(?:gltf|bin|obj|usdz|glb)$/i,
              use: [
                {
                  loader: 'file-loader',
                  options: {
                    name: path.posix.join(
                      'assets',
                      'files',
                      '[name]-[contenthash].[ext]',
                    ),
                    emitFile: !isServer,
                  },
                },
              ],
            },
          ],
        },
      };
    },
  };
};

Ideally the docs should be clearer about how to support these additional static assets...

@slorber
Copy link
Collaborator Author

slorber commented Jan 7, 2025

We were scratching our heads, so we compared versions and discovered that docusaurus had changed their underlying version - which to me this is a breaking change...

Not sure what you mean by "underlying version"?

If you upgraded Docusaurus, then it's you who changed the version right? It isn't supposed to happen automatically, at least if you use a lock file.

Now I agree: this behavior should not break in v3.x so I mistakenly shipped a breaking change that I'm reverting in the upcoming v3.7.1 release.

We don't use the preset because we have a custom theme, so we loaded individual plugins as needed.

I see thanks for providing the context.

We fixed it by loading the plugin that you introduced directly into our docusaurus configuration, and it worked.

Yes it works, although it's a bit awkward to have to do so if you don't plan to use SVGR. That's why I'm fixing it for v3.7.1: so that you don't need to do this awkward thing.

Sometimes we also make use of assets that docusaurus's existing webpack configuration doesn't support, so we customise loader plugin too
Ideally the docs should be clearer about how to support these additional static assets...

The doc explains you can use configureWebpack for advanced needs. There's an infinite number of advanced needs that webpack allows you to configure, we can't document them all, and the webpack documentation is for that.

Also, we try to abstract the underlying bundler as best as we can. If someday we decide to change bundler and use let's say Rolldown, Bun, or esbuilt, then your code breaks. We don't particularly want to encourage you to extend our webpack config unless you really need to (which you need in this case). We won't provide "pre-made recipes", if you do it, you must understand what you are doing and be ready to read the whole webpack doc if needed.

That being say, we'll later explore using Unplugin so that we can let users extend the bundler in a more portable/agnostic way.

And having a first-class Docusaurus feature to register new file/image extensions could make sense too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Argos Add this label to run UI visual regression tests. See argos.yml GH action. CLA Signed Signed Facebook CLA pr: new feature This PR adds a new API or behavior.
Projects
None yet
3 participants