jhamlet / svg-react-loader

Webpack SVG to React Component Loader
MIT License
559 stars 82 forks source link

Failure with some svg tags #12

Closed MoOx closed 8 years ago

MoOx commented 8 years ago
ModuleParseError: Module parse failed: /Users/MoOx/Sync/Development/statinamic/docs/node_modules/svg-react-loader/index.js!/Users/MoOx/Sync/Development/statinamic/logo/statinamic-text.svg Line 21: Unexpected token <
You may need an appropriate loader to handle this file type.
| 
|         return (
|             <svg {...this.props}>
|                   <title>statinamic</title>
|   <desc>Created with Sketch.</desc>

It seems desc and title should be removed.

jhamlet commented 8 years ago

Do you have a svg file you can attach that I can reproduce the issue?

MoOx commented 8 years ago

https://raw.githubusercontent.com/MoOx/statinamic/4093478de3da8f1ccba3c328b253b12b92f7479f/logo/statinamic-text.svg

A workaround is using svgo-loader before with { removeTitle: true } in plugins.

jhamlet commented 8 years ago

title and desc are valid svg element tag names... but, maybe not within React...

Are you using babel in your loader pipeline?

MoOx commented 8 years ago

I was using it in a weird context, on server side https://github.com/istarkov/babel-plugin-webpack-loaders, so got stuck with another issue.