angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Assets not working after update

Open FunnyGhost opened this issue 9 years ago • 23 comments

Please provide us with the following information:

OS?

Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?) Windows 10

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-rc.1 node: 7.4.0 os: win32 x64 @angular/common: 2.4.9 @angular/compiler: 2.4.9 @angular/core: 2.4.9 @angular/forms: 2.4.9 @angular/http: 2.4.9 @angular/platform-browser: 2.4. @angular/platform-browser-dynam @angular/router: 3.4.9 @angular/compiler-cli: 2.4.9

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc. The app was created with Angular-CLI

The log given by the failure.

Normally this include a stack trace and some more information.

Mention any other details that might be useful.

I have several images in my src/assets folder. In the html for different components I used to reference them like this: href="/assets/some-name.ico". This worked before the update. Now it expects a folder src/assets in the dist folder. Not sure what's wrong. In the angular-cli I have this:

      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],

Thanks! We'll be in touch soon.

FunnyGhost avatar Mar 07 '17 08:03 FunnyGhost

Hey guys! I'm new to angular and I'm facing the same problem in my app where the local version works perfectly great whereas the github deployment breaks all the URLs for images. My images are placed in src/assets/xyz.jpg directory and I have tried changing the base href as well as my image url and still the image appears to be broken.

I'm using angular 6. Would be really thankful if I get my issue sorted out.

Thanks in advance.

demiahmed avatar Jul 09 '18 10:07 demiahmed

@demiahmed > in developer tools you can see why... It is because the path to your images is wrong. All of your files are downloaded from for example localhost/AngularApp/ so your images are on localhost/AngularApp/assets .... but unfortunately, the browser looks for them on localhost/assets and that's why it doesn't get anything.

solution:

save img URL in this format: './assets/fries.png'

PavelFranta avatar Oct 29 '18 13:10 PavelFranta

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.