-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
importing svg breaks component in production. #2669
Comments
Please fill the issue template. There is too little information to help you. We'll need an example reproducing the issue. |
Is this a bug report? No this is a question about inlined svgs that is not answered in the issue docs or the user guide. Can you also reproduce the problem with npm 4.x? I am using npm 4.2 Which terms did you search for in User Guide? I read over the adding images fonts and files section after searching "svg" as well as "valid react element". My question is - is there a way to automatically pull all svgs into the build directory instead of doing it manually ? Because I have material UI components that have svgs embedded within them and I'm not easily able to find and place them in the build directory ? Environment Add an svg inlined to a react component like so import svgIcon from './svg_icon.svg' then run yarn run build and yarn run serve. Expected behaviour teh svg should be pulled into the build directory. I understand that issue #1180 created an exception for svgs to not be inlined. What is not obvious to me from looking at the user guide and the issue comments is WHAT do we do when we want svgs to be loaded into the list of static assets, bc at this time they are not being loaded at all. Actual Behavior If I run yarn run build and yarn run serve, the componet with the inline svg will fail to load and return an error 105. If I then manually add the svg into the build directory, then the component does render. |
#2065 this sounds very similar to what I am experiencing. |
Closing this, I've upgraded to 1.08. However external svgs from other component libraires are still not loading, however I'll do more reading to see if this has been solved. Thanks @gaearon ! |
Sorry, what I meant is that we couldn't help you without a project reproducing it (last section of the issue template). Glad to hear it's working in latest version! |
Ok first time posting an issue so be kind :)
Node version 7.9
npm 4.2
yarn 0.20.3
react scripts 0.9.5
Mac mac sierra ox10.12.3
When I run in development my app works fine, however when I switch to production any component that has an SVG like this:
import SvgIcon from './svgIcon.svg'
returns with the following error.
https://facebook.github.io/react/docs/error-decoder.html?invariant=105&args[]=HardwareSmartphone
When I remove the svg and replace with a png the component renders fine.
Please let me know if I need to answer anything else ?
The text was updated successfully, but these errors were encountered: