Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with url-loader breaks svg imports inside LESS files #43

Closed
ppozniak opened this issue Jan 26, 2018 · 2 comments
Closed

Usage with url-loader breaks svg imports inside LESS files #43

ppozniak opened this issue Jan 26, 2018 · 2 comments

Comments

@ppozniak
Copy link

Hello there.

Not quite sure if this is a problem with this library, or my setup, however I wanted to keep all the SVG imports as they are, in addition of using import {ReactComponent as Icon} from '...' in React Components.

Here's how my setup looked liked before adding svgr

  {
    test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
    loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
  },

And after

{
    test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
    use: ['babel-loader', 'svgr/webpack', 'url-loader?limit=10000&mimetype=image/svg+xml']
  }

Everything works fine except importing SVG's inside of LESS files (specifically speaking Iconmoon import):
url('@{icomoon-font-path}/myfontsvg?clelyn#myfont') format('svg');
There were no errors, but all icons were appearing as rectangles [].

Please let me know if this is an issue with svgr, or I'm doing something in a wrong way.
Best regards.

P.S I've found a workaround, just want to be sure this isn't my fault :)
The workaround

  {
    test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
    issuer: {
      test: /\.jsx?$/
    },
    use: ['babel-loader', 'svgr/webpack', 'url-loader?limit=10000&mimetype=image/svg+xml']
  },
  {
    test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
    loader: 'url-loader?limit=10000&mimetype=image/svg+xml'
  },
@gregberge
Copy link
Owner

Actually it is an issue and your workaround is the good one. I think @gaearon had the same problem on react-create-app.

@gregberge
Copy link
Owner

I have to document it in Readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants