Skip to content

Webpack skips images referenced in html templates (img src) #2231

Closed
@alexsorokoletov

Description

@alexsorokoletov

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)
OS X El Capitan
  1. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:
angular-cli: 1.0.0-beta.14
node: 6.3.0
os: darwin x64
  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    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

  1. The log given by the failure. Normally this include a stack trace and some
    more information.
    Image is not being bundled into dist folder and is not loading producing 404 error.
  2. Mention any other details that might be useful.
    Problem is reproduced with ng build -prod and is not reproduced with ng 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


Thanks! We'll be in touch soon.

Metadata

Metadata

Assignees

Labels

P3An issue that is relevant to core functions, but does not impede progress. Important, but not urgenttype: bug/fix

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions