Unexpected token: name (SVG)
See original GitHub issue2.0.0-alpha.1
My webpack loader config is the default one
{
test: /\.(svg)$/,
use: [{
loader: 'react-svg-loader'
}]
}
Which outputs
class SVG extends __WEBPACK_IMPORTED_MODULE_0_react___default.a.Component {
render() {
return __WEBPACK_IMPORTED_MODULE_0_react___default.a.createElement(
"svg",
And the error is:
[19:53:28] Error: Fix the following webpack build errors:
main.2de7c4a952203664e4cf.js from UglifyJs
Unexpected token: name (SVG)
So it doesn’t compile class
to ES5 syntax.
What is the Webpack loader config for the default behaviour with ES5 transpilation?
Perhaps it would make sense to make it the default behaviour since no one would use class
es in their JS currently.
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Jest: SVG require causes "SyntaxError: Unexpected token <"
Edit: It appears to be happening the first place where i use require to load a static .svg file. Why can it not...
Read more >@svgr/webpack - npm
The named export defaults to ReactComponent , but can be customized with the namedExport option. Please note that by default, @svgr/webpack ...
Read more >Managing inline SVGs with React/Webpack - union.io
A t work this week, I found myself tasked with developing something that sounded fairly simple: A React web component that accepts the...
Read more >Field "field name" contains invalid expression with error - Search
ERROR: Field "field name" contains invalid expression with error: "Unexpected token "{" in path expression" while using parseJSON function in ...
Read more >Unexpected token < in JSON at position 31 : r/react - Reddit
Can't say anything concrete without the package.json, but just from the character (<), it could be due to an improper resolution of a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, I got it now, it seems to work – the latest
2.0.0-alpha.1
version has to be used, not@latest
which is1.x
. And the correct Webpack config is:This is still more verbose than
svg-react-loader
and alsosvg-react-loader
handles<style/>
tags and CSS classes (and this library gave me errors so I migrated<style/>
tags inside SVG to inline styles by hand). But at the same time the author ofsvg-react-loader
doesn’t communicate at all in the issues and PRs. This issue is resolved then.UPDATE Migrating back to
react-svg-loader
becausesvg-react-loader
has a filename bug https://github.com/jhamlet/svg-react-loader/issues/72Thanks!! I was able to solve issue.