Description
Please provide us with the following information:
OS?
Windows 10 x64
Versions.
@angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.28.3]
node: 7.2.0
os: win32 x64
@angular/common: 2.4.7
@angular/compiler: 2.4.7
@angular/core: 2.4.7
@angular/forms: 2.4.7
@angular/http: 2.4.7
@angular/platform-browser: 2.4.7
@angular/platform-browser-dynamic: 2.4.7
@angular/router: 3.4.7
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.7
Repro steps.
create an app with ng-cli. create a build for a server (not ng serve) with base-href set to xxx. use url's in scss (like background-image: url('/assets/img/myimg'). the imagepath for the url will be set to server/assets/img/myimg instead of server/xxx/assets/img/myimg. If I try to use a relative path in the scss (ie url('./assets/img/myimg') ) i get a compileerror, that this is not resolveable. If i try to use url('assets/img/myimg') this is also not resolveable for the compiler.
my .angular-cli.json has this section:
"assets": [
"assets",
"favicon.ico"
],
The log given by the failure.
There is only a compileerror that the path is not resolveable or a runtime 404 when the resource is not found without using the base-ref in the url.
Mention any other details that might be useful.
There is a workaround for this issue: i set the style in my component directly and inject it like this:
<span ... [style.background-image]="getLogo()">
getLogo() {
return this._domSanitizer.bypassSecurityTrustStyle(url(${this.logosrc}
);
}
where logosrc = "./assets/img/myimg"
Thanks! We'll be in touch soon.