Closed nicgordon closed 6 years ago
this is raised by sax parser , the module analysing your svg. It seems it has encountered a char it doesn't appreciate
i encourage you to open your svg with a good text editor like notepad++, and activate option to see all invisible white chars. You'll be able to see incriminated char and shoot it. try again after this
See, I don't think that's the case. The problem is that the parser is literally coming across this string:
module.exports = __webpack_public_path__ + "d9fb6acead094090c1450fa6f4b6c5b7.svg";
which is why it sees an m
as the first character. I imagine that the parser would normally expect to see something like <svg xmlns="...
at that time. The problem is not in invisible chars, it is that the transformation seems to have already happened before the parser runs?
And fwiw I did save my files as UTF-8 encoding without BOM to eliminate that as the reason.
ok so it pay comes from the order of your loaders for svg files. I have had this issue before. you can see if you have any loader out of svg-react-loader in your config, and eventually exclude svg from it.
moreover do no not forget loaders are called in the inverse order of lines in your webpack.config file
@nebaff that was the solution for me, I needed to move my svg-react-loader
test under my fallback svg loader. I was under the impression that my loaders applied in the opposite order. Thank you!
Any chance you could post your code @nicgordon :)?
this may be and old thread but I came across this same error, make sure you set a defined loader for the file. Especially if you have other loaders with svg definitions
import Icon from '-!svg-react-loader./icon/path/name.svg';
I had this same issue but am using a root import plugin, so mine ended up looking like:
import Icon from '-!svg-react-loader!src/assets/images/name.svg'
(note the 2nd bang '!' after '-svg-react-loader')
Sorry to raise an issue with this name again, but I believe that this is not related to the BOM issue that was closed previously. I am wondering if I am doing something silly with my webpack config that is causing this:
So you'll notice the char it comes across is an 'm', so I decided to see what it was seeing and logged out before this line
svg-react-loader/lib/xml/parse.js:16:16
and got this:It seems that the loader has already done its magic by this point. So why am I getting this warning? Is it running twice? This is how my loader is configured:
Any help would be appreciated. Thanks!