-
Notifications
You must be signed in to change notification settings - Fork 12k
Webpack skips images referenced in html templates (img src) #2231
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
I've been having similar issues. In |
Assets is a different story. However, the asset images are just file copied to dist folder and are not optimized in any way. Alex
|
As far as I can tell, we don't process html and just load it as is - but we process css and thus inline stuff. @TheLarkInn is there a good way to inline images in html? https://github.com/webpack/html-loader seems to offer options to do it, but I get the feeling there was a reason why we didn't do that. |
@filipesilva thank you for looking into this. Would love to have a way to bundle images in html or other suggested way to have images in html optimized. Additionally, having a sample right inside a new project template would be awesome. |
I think we can simply do this through html-loader. There isn't a reason I see that we shouldn't. Let me whip up a PR for this. |
What if I've got two folders with assets? Don't ask why, but I've got an "img" folder and an "images" folder. It does not seem to support an array.... @kidshenlong |
This ticket as far as I know is not about assets folder and assets behavior |
We added this functionality in beta.16, but are actually looking at removing it due to #2396. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
ng --version
. If there's nothing outputted, please runin a Terminal:
node --version
and paste the result here:do on your code? etc.
Create new project with
ng new test-project
Add images folder to src (and you can add to src/app, doesn't matter).
Reference image in app.component.html
<img src="images/image.png" alt="test" />
Build project with
ng build -prod
more information.
Image is not being bundled into dist folder and is not loading producing 404 error.
Problem is reproduced with
ng build -prod
and is not reproduced withng serve -prod
.github repo showing problem: https://github.com/alexsorokoletov/angular-cli-image-loader-problem
I am not sure if this is a problem of webpack html loader plugin or issue related to it's configuration or I am doing something wrong.
For a workaround I am using
assets
folder and put all images there.However, it is strange to me keeping some images in assets and some (that are mentioned in the css files) inside the webpack bundle
The text was updated successfully, but these errors were encountered: