Components doesn't ship with images properly
See original GitHub issueCurrent Behavior
I have been trying to create a react component with images for the purpose of reusing them across different apps.
However, when I build the library and import the component, the component works fine except all the images are not referenced properly
I also tried running Storybook and I got the same issue.
Expected behavior
Build process should ship images properly
Suggested solution(s)
Additional context
- I run
tsdx build
on theprepare
script in thepackage.json
- I tried using
babel-plugin-file-loader
,rollup-plugin-url
androllup-plugin-image
but they didn’t work.
Your environment
Software | Version(s) |
---|---|
TSDX | 0.9.3 |
TypeScript | 3.6.2 |
Browser | Chrome Version 77.0.3865.120 |
npm/Yarn | Yarn 1.19.1 |
Node | 10.15.3 |
Operating System | MacOS Mojave 10.14.6 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7
Top Results From Across the Web
img not showing up in styled components reactjs
Image path is correct. But image is not showing up. HTML img is showing up in the DOM, but not include src attribute....
Read more >Image not appearing on Lightning Component [duplicate]
In my below lightning component , I am trying to display an image using background image tag. <div class="imageview" style="{!'background-image: ...
Read more >Different Parts Of A Ship Explained - Marine Insight
Three necessary parts of the ship are the hull (the main body of the vessel), navigation bridge (helps in directing the ship in...
Read more >12 Important Image SEO Tips You Need To Know
Discover which factors are essential for optimizing images to improve your content and help it rank higher in search.
Read more >How to properly pack and ship a PC! - YouTube
Today I prepare Kiapiaa's PC for shipment, but there are some important steps to take to ensure that it arrives safe and sound!...
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
Sharing my config workaround to get images to work with
tsdx
.It seems like your
rollup
plugin to handle images needs to come beforetsdx
’s plugins. (I’m guessing beforerollup-plugin-typescript2
?).I tried to get this working with
@rollup/plugin-url
, but couldn’t figure it out. If anyone is interested, my config with@rollup/plugin-url
can be seen below.Maintainer edit: updated to reflect v0.13.0+
The main problem seems to be that
@rollup/plugin-url
will generate a plain string instead of leveraging arequire
when you try to use an asset, which wont signal to a library consumer’s bundler to properly generate the path for their project. (can be seen in action with Parcel in theexample/
directory)Going to close the out since a solution was found. See https://github.com/jaredpalmer/tsdx/issues/379#issuecomment-568239477 for the summary from here.
Import order seems to affect this specific plugin. I’m not really sure why
@rollup/plugin-url
doesn’t work