-
-
Notifications
You must be signed in to change notification settings - Fork 27k
react-scripts v4.0.0 causes local images to not load #9992
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
In absolute terms, where are these images located? inside or outside the |
Inside |
downgrade the version of react-scripts, thats works for me. I downgrade to 3.4.4 . |
I recomend to downgrade react-scripts to 3.4.4 that bug does not happened anymore with that version, i hope that they fix that bug in the next patch |
I have submitted a PR to fix this issue in #9934 |
try |
I don't know if this is the same issue but in 3.x this worked
Where app.js does Works in 3.x, fails in 4.0 with
|
@greggman how/have you fixed this? |
For now I just reverted to 3.x I haven't had time to check if @n3tr 's patch is related or not |
I have to use |
I can confirm this issue. |
+1 images are not loading after upgrading to react-scripts 4.0.0 |
same here, updated to react-scripts v4.0.0 and images are not loading anymore |
Issue still there |
Issue is still here -- thank you. |
Some of us have 3rd party things in our public folder that are not part of the build. We used to be able to reference those things. Now we can't |
Just use normal import import logo from '../../assets/images/logo/logo-v4.png' it should work. For some reasons require is importing images as modules. |
How is this still an issue? Was this intended? Do I need to update all my projects using |
I have this issue too I spend a day on it, this should be fixed...... |
how do we solve the problem for loading images dynamically, say my image name depends on a variable require("../../assets/images/others/"+loginBgImage) loginBgImage can have different values (login-image.jpg, login-new-image.jpg) this got fixed using require("../../assets/images/others/"+loginBgImage).default |
this worked for me with react-scripts 4.0.3 I was also seeing that immer version warning when i rolled back to 3.4.4 |
Ugh, I've been hit by this too. Spent longer than I care to admit trying to figure out what the problem was. I had a broken serviceWorker to deal with as well - and mistakenly thought both were the same problem 🤦 Adding the |
Bump. Not fixed. Currently using |
Try this it will definitely work |
Try this it will definitely work |
Nice work for me! Thanks. |
Importing file types that are supported ( Using |
Thanks, i used this way and it's running ok |
This issue has been automatically marked as stale because it has not had any recent activity. It will be closed in 5 days if no further activity occurs. |
This issue is still present in v5.0.0 |
I stumbled over this issue because after the upgrade from v4.0.3 to v5.0.0 some of my imports broke. I discovered the following with image require calls in v5.0.0:
Importing it normally worked for both cases. I didn't test any other file extensions. I'm wondering if there's any documentation for this. EDIT: Found the definition: |
it seems to be no, v5.0.1 in my case, require png with default get undefined, direct require get normal base64, in v4 i almost totally use require.default, but now seems to should remove them all, it is a tough work. by the way, i have reject the project, i don`t know if it makes a difference |
issue still present |
Describe the bug
Upgrading from v3.4.4 to v4.0.0 (using
npm install react-scripts@latest
) causes my local images (usingsrc={require("../../assets/images/logo/logo-v4.png")}
) to not load, however external images load. (see StackOverflow post here ) Fixed by simply downgrading to v3.4.4.Environment
Tested using MacOS Catalina v10.15.7 and Windows 10 on Chrome Version 86.0.4240.111
The text was updated successfully, but these errors were encountered: