Skip to content
This repository has been archived by the owner on Sep 4, 2023. It is now read-only.

Load image inside a partial #425

Closed
El-Tommy opened this issue Dec 28, 2022 · 1 comment
Closed

Load image inside a partial #425

El-Tommy opened this issue Dec 28, 2022 · 1 comment

Comments

@El-Tommy
Copy link

El-Tommy commented Dec 28, 2022

In my question it was shown how to load an image inside a main file (eg.: page-index, page-contact, etc) using the direct require of the image or template mode of an HTML file with the image tag.

However, on my site I used a partial (nav.html) to insert an image, and using <%= require('../../partials/nav.html?raw') %> didn't work (dont load the image), but by changing to <%= require('../../partials/nav.html?template').default %> the image loaded correctly along with the code.

Is this way correct? I ask this because this repository is helping me a lot to make a website, but this is the first time I use Webpack and I have no idea how the html-loader works.

And when I run npm run build, the images inside index.html are not in an img folder, but directly in the root.

@ivarprudnikov
Copy link
Owner

There is an example of loading images. In one case it is just like you are describing:
https://github.com/ivarprudnikov/webpack-static-html-pages/blob/master/src/page-about/tmpl.html#L23-L26

Please let me know if it does not help.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants