Skip to content
Discussion options

You must be logged in to vote

Webpack allows you to force-override the active loaders for a given file extension:
https://webpack.js.org/concepts/loaders/#inline

It's not super portable (we may move off Webpack later) but you can force this way the usage of:

  • file-loader/url-loader: gives you an URL of the SVG asset
  • raw-loader: gives you the source string of the SVG asset

One example is documented here: https://docusaurus.io/docs/markdown-features/react#importing-code-snippets


Note: if your SVG is in /static you can just reference it without importing it:

<img src="/docs/path/to/my/asset.svg" clickable />

An alternative is to use configureWebpack() to register an Asset Modules config: https://webpack.js.org/guides/…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@tobi1220
Comment options

@slorber
Comment options

slorber Aug 3, 2023
Collaborator

@tobi1220
Comment options

@tobi1220
Comment options

Answer selected by tobi1220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants