Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Issue with asset/modules, while loading the image through css, with frontend and backend server being different. #18416

Closed
Chinmay2709 opened this issue May 21, 2024 · 0 comments

Comments

@Chinmay2709
Copy link

Before I explain the issue that I have in my case, here is my general info:
webpack-cli INFO

Now, here is my project description:

  • I am developing a Vue application.
  • I am using tailwind-css in my application.
  • my back-end is on python flask.
  • I am using xampp apache to serve my application on : ( URL: http://127.0.0.1:80/)
  • And my Front-end web-pack server runs on: (URL: http://127.0.0.1:8080/bundle.js)
  • Therefore my Project structure is something like this:

project-struc

Now coming back to problem.
So far everything was working fine, since I'm using web-pack V-5, I was aware that the url-loader and file-loader are depreciated, and instead asset/modules are introduced. Therefore, that's what I used, here is my webpack.config.js :

webpackconfig

Even after that when I run my project I, couldn't load my Image to the project:

Browser debugger image prob

Now, here is what I found, the problem was never with web-pack or with my path inside my main.css file which has property(background-image) with url for the image. I found that the problem is with the dynamic URL with hash for image that is loaded by the web-pack, since I am using a different PORT ( 8080 ) for my bundle.js, the web-pack loads the file with URL without the port number, which creates a problem. Here, is how when I change or add port number to URL, image seems to be loading.

Screenshot 2024-05-21 183755

Now here is my question:

Is there a way I can give correct port to the web-pack so that it knows the correct URL to reach my asset ? or if not then what should be my approach, given that my back-end would remain on python, since I have specific use for the language.

Thanks~

@webpack webpack locked and limited conversation to collaborators May 29, 2024
@alexander-akait alexander-akait converted this issue into discussion #18437 May 29, 2024

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant