You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Webpack is emitting my spritesheet, having been loaded by svg-sprite-loader and then extracted, but it cannot be resolved. This has happened since upgrading, both webpack from 4 to 5, and html-webpack-plugin to the latest version.
An answer to a stackoverflow question suggested that it's related to how it tries to resolve xlink:href="svg/spritesheet.svg#logo" in the html. Specifically <svg><use xlink:href="svg/spritesheet.svg#logo"></svg>
I think it's trying to resolve it from the filesystem before it actually exists
I still don't understand why html-webpack-plugin tries to resolve the path, though. It's probably treating the path as an entry and likely it was a breaking change in their 5.0 which you can work around somehow
Juho in that SO question suggested using his plugin as a fix, which I'm grateful for, and it does work, but I'm more familiar with yours, and I thought this might be of interest? For the time being I'll probably use his or lazy load the svgs in image tags as he suggests.
Apologies for the wall of text!
The text was updated successfully, but these errors were encountered:
Current behaviour 💣
Webpack is emitting my spritesheet, having been loaded by
svg-sprite-loader
and then extracted, but it cannot be resolved. This has happened since upgrading, both webpack from 4 to 5, andhtml-webpack-plugin
to the latest version.An answer to a stackoverflow question suggested that it's related to how it tries to resolve
xlink:href="svg/spritesheet.svg#logo"
in the html. Specifically<svg><use xlink:href="svg/spritesheet.svg#logo"></svg>
SO question
The spritesheet is emitted, but I get the error:
Expected behaviour ☀️
For html-webpack-plugin to treat the asset as it did in older versions
Reproduction Example 👾
Repo
Will leave the problem on the master branch
webpack.config.js from repo:
Asset in html:
<svg class="mx-auto my-16"><use xlink:href="svg/spritesheet.svg#logo"></svg>
Asset import in index.ts:
import './images/logo.svg';
Environment 🖥
Juho in that SO question suggested using his plugin as a fix, which I'm grateful for, and it does work, but I'm more familiar with yours, and I thought this might be of interest? For the time being I'll probably use his or lazy load the svgs in image tags as he suggests.
Apologies for the wall of text!
The text was updated successfully, but these errors were encountered: