Assets/Images not being served...
Versions
Angular CLI: 1.6.6
Node: 6.9.4
OS: win32 x64
Angular: 5.2.2
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.6
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.6
@schematics/angular: 0.1.17
typescript: 2.5.3
webpack: 3.10.0
Repro steps
- add any image to /src/assets/images/
- reference image in HTML
- ng serve
Observed behavior
image is not found Request URL:http://localhost:4200/assets/images/logo.png Request Method:GET Status Code:404 Not Found
I have made sure that my angular-cli.json lists the assets folder...
Assets folder directly under src directory
HTML is typical
<img src="./assets/images/logo.png"/>
Image is 404

Here is a minimal example... https://github.com/smatthews1999/testng
I am also getting the same error ... and on looking under networks tab found the following difference between the type of my two separate .png images. Both images have the same size and I am adding them in the html file as
<img class="img-thumbnail rounded mr-3 anim-zoomin" style="width:40%;height:auto" src="assets/images/image.png" alt="Generic placeholder image">

Does anyone have an idea of what does this mean? or how could I resolve it ?
I've run into the same issue I think and posted on stack here: angular-8-assets-not-loading and was told to update this thread (hope that's ok :-) ).
Basically check the full path, I had parenthesis in mine and that stopped the assets from working.
- myTestApp2 => works
- 'my test' => works
- 'my test(12)' => doesn't work
Hope it helps someone !
For anyone still having this issue, this was fixed it for me:
Open your tsconfig.json file (It is in the top level of your workspace directory).
Change this:
"outDir": "./dist/out-tsc",
to this:
"outDir": "./dist"
This answer was gotten from https://stackoverflow.com/a/56206651 where you can see the rest of it.
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.