JetBrains / svg-sprite-loader

Webpack loader for creating SVG sprites.
MIT License
2.01k stars 272 forks source link

Webpack 5! Is svg-sprite-loader compatible with Webpack 5? #479

Open Borovensky opened 2 years ago

Borovensky commented 2 years ago

Webpack 5! Is svg-sprite-loader compatible with Webpack 5? I update my application from 4 to 5 webpack and seems sprite stop working properly. svg-sprite-loader is not generated symbol anymore, instead I got this data data:image/svg+xml;base64

Current behavior I receive this as output: Screenshot from 2022-01-14 15-13-03

Expected behavior With webpack 4 I have this: Screenshot from 2022-01-14 13-01-04

This is a part of my webpack config Screenshot from 2022-01-14 15-35-32

environment:

I tried many cases and config changes...but with no success. I don't know even to what I should pay attention, because there are no visible errors while building the app. also there is no info in readme regarding webpack5.

I would really appreciate any help. Thanks.

chrisands commented 2 years ago

Here #470 I posted diff that also adds webpack@5 support.

Borovensky commented 2 years ago

Hi @chrisands. Thanks. I will check it out.

luckydrq commented 1 year ago

Set Rule.type to javascript/auto works for me.

image

EricHan0723 commented 1 year ago

Set Rule.type to javascript/auto works for me.

image

seems work for me too

uglu commented 1 year ago

Set Rule.type to javascript/auto works for me.

image

This needs to be added to the documentation. I searched for this solution almost an entire day. Is it a webpack or a loader specific config? In my case, i was doing a require.context for the svgs and importing them all from a folder. Before i upgraded webpack, i was getting actual modules but after the upgrade i was just getting strings

const requireContext = require.context('./assets/svg', true, /\.svg$/)
requireContext.keys().forEach(requireContext)