Kokulan
Kokulan

Reputation: 1364

Angular cli assets photo issue - giving 404 not found

I'm trying to import the image file from assets folder like this background: url('../../assets/img/drag-icon.png')

it gives this error and doesn't load the image http://localhost:4200/assets/img/drag-icon.png

I couldn't find those images in dist as well

This is my angularcli.json

{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "project": { "name": "app-name" }, "apps": [ { "root": "src", "outDir": "dist", "assets": [ "[assets]", "favicon.ico" ], "index": "index.html", "main": "main.ts", "polyfills": "polyfills.ts", "test": "test.ts", "tsconfig": "tsconfig.app.json", "testTsconfig": "tsconfig.spec.json", "prefix": "wf", "styles": [ "styles.scss" ], "scripts": [], "environmentSource": "environments/environment.ts", "environments": { "dev": "environments/environment.ts", "prod": "environments/environment.prod.ts" } } ], "e2e": { "protractor": { "config": "./protractor.conf.js" } }, "lint": [ { "project": "src/tsconfig.app.json" }, { "project": "src/tsconfig.spec.json" }, { "project": "e2e/tsconfig.e2e.json" } ], "test": { "karma": { "config": "./karma.conf.js" } }, "defaults": { "styleExt": "scss", "component": {} } }

Upvotes: 0

Views: 6999

Answers (1)

Shailesh Ladumor
Shailesh Ladumor

Reputation: 7242

in your angular cli you need to set you asset dir. angular-cli.json

 "apps": [
        {
          "root": "src",
          "outDir": "dist",
          "assets": [
            "assets", // set here your whatever dir  where you store images
            "favicon.ico"

Make Sure your dir in angular cli.

Upvotes: 3

Related Questions