-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 PNG/SVG from node_modules failing #1909
Comments
Additional reproduction - https://codesandbox.io/s/gallant-satoshi-mhrnz?file=/app/routes/index.tsx |
I believe what we want is to essentially "bundle" any file extension we support loaders for. Essentially this: https://github.com/remix-run/remix/blob/dev/packages/remix-dev/compiler/plugins/serverBareModulesPlugin.ts#L46 I believe these are being "externalized" currently and for assets I'm not sure what that means for the output bundle. |
Still reproducible with 1.11.1 |
The serverBareModulesPlugin.ts link above is broken. https://github.com/remix-run/remix/blob/212f17cfd4f51df27a23575273828f30c1d072d3/packages/remix-dev/compiler/plugins/serverBareModulesPlugin.ts is a more recent version of the relevant module. |
Any updates on this? I'm encountering the same issue. Is there a short term solution where I can patch Remix to support importing .svg files as urls? |
@augustskare here's a PR doing what you want, but for CSV files: https://github.com/remix-run/remix/pull/3920/files |
@machour Not sure I understand what to do. |
@augustskare Remix only imports assets from inside the /app folder. import imgPath from '~/assets/image.png' I don't believe you can import an image directly from node_modules. You may need to copy those images to your app folder. |
I guess that's why my current workaround works:
|
Ah. Cool to know that you can use relative paths to escape outside the app folder. Glad you found a workaround. |
It's a bit more complex then that 🙈 I have an internal design system/component library that is importing that svg file. Ended up copying over the component so that I could modified the import. I can live with that for now. Any idea if this is something that will be supported in Remix any time soon? |
I'm not sure. They've been able to move quickly by not exposing the compiler internals quite yet. Perhaps they'll relax that more as they move to v2 release. |
Found a better workaround! ✨ Adding the package to the |
@augustskare Thank you SO much for this issue/thread. It is quite ugly, but importing the SVG file with a relative path going into the |
Definitely still broken in 1.18.1. |
Fixed by #6813 |
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
What version of Remix are you using?
1.1.3
Steps to Reproduce
uswds
NPM moduleapp/routes/index.tsx
, import an image withimport img from 'uswds/img/circle-124.png'
and put on the page with<img src={img} alt="" />
npm run dev
and load up the page.Expected Behavior
Circle image should be displayed
Actual Behavior
I get the following error:
The text was updated successfully, but these errors were encountered: