Skip to content

No longer able to use relative URL in LESS to reference images in src/assets in beta.32 #4858

Closed
@LyraelRayne

Description

@LyraelRayne

Please provide us with the following information:

OS?

OSX Sierra

Versions.

@angular/cli: 1.0.0-beta.32
node: 7.3.0
os: darwin x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32
@angular/compiler-cli: 2.4.8

Repro steps.

  1. ng new test
  2. cd test
  3. ng g component test
  4. mv src/app/test/test.component.css src/app/test/test.component.less
  5. edit src/app/test/test.component.ts to reference the less file instead of css
  6. put an image file (I used sample.svg) into the src/assets folder.
  7. Put the following in src/app/test/test.component.less

.nothing {
background: url("assets/sample.svg");
}

  1. ng build

The log given by the failure.

ERROR in ./src/app/test/test.component.less
Module not found: Error: Can't resolve './assets/sample.svg' in

'/Users/lyrael/test/src/app/test'
@ ./src/app/test/test.component.less 6:60-90
@ ./src/app/test/test.component.ts
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts

Mention any other details that might be useful.

This exact setup worked fine in beta.30 but did not in .32 .

Note that the CSS specifies "assets/sample.svg" but the error says "./assets/sample.svg". I suspect something in the new version is "fixing" (i.e. breaking) my URL path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions