0

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": {} } }

4
  • use ./assets/ .... Commented Jul 6, 2017 at 11:09
  • tried it didn't work Commented Jul 6, 2017 at 11:19
  • i couldn't find those images in dist as well Commented Jul 6, 2017 at 11:19
  • match your cli and my answer. replace [assets] to assets Commented Jul 6, 2017 at 11:42

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.