-
-
Notifications
You must be signed in to change notification settings - Fork 27k
Array's of images #2545
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
Comments
put static images in your |
Hello @themre that doesn't resolve my problem, i'm not putting my files (and i dont needed) put on public folder. I can do all my changes on src, and webpack can put them on public folder. So i think that is not a good solution. But i had tried, and when the page had render, the img is not on my src/img directory. And can't understand why... if you need, i can put printscreen of that. Many Thanks Pedro Cruz |
webpack isn't able to analyze this, but the fix should be relatively simple. Change export default [
require('./img/header.jpg'),
require('./img/header1.jpg')
] Change import * as data from "../resources/slider.json"; to import data from '../resources/slider'; |
Your |
Well, i know that's a good solution, but if my app needs json, this bundle can't resolve this? :| i think that is a possible request . EDIT: btw, that solution, the result is this:
and @bondz it's exactly the same. When page rendered's the result is the same. EDIT2: Sorry wrong path. is not on ./src/img/header.jpg , but yes on ../img/header.jpg :) But in any case, i prefer with json. If can anyone resolve that i aprecciate that! |
It cannot be done with json unless if you use the public folder. Sorry! I'll close this as resolved, since you said the |
lol, it's not suposse to use public folder... So, what's the reason to use webpack? |
If you this desperately want to keep json, just do this: import * as data from '../resources/slider.json'
/* This should properly require images with WebPack */
data.forEach((imagePath) => require(imagePath))
/* ... rest of your code */ This is quite crude example, adjust it to your needs, but I hope you've catched the idea. |
thanks for that @ArmorDarks , but cant require the imagePath, can't understand what's the problem... require module not found. |
Hello @Timer and @ArmorDarks , I want webpack to manage my images as I want the service worker to cache them. Thank You |
Hello people,
Well, my problem is about images. imagine the problem, that in my div parent, only have tags img children or 1 or more than 1. And i put that img src's on a array like:
-- slider.json --
And this is my React component:
My problem i think, its for webpack seeing the img src, i cant see the image... How i can resolve this?
Kind Regards,
Pedro Cruz
The text was updated successfully, but these errors were encountered: