You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Yes, this behavior used to work in the previous version
The previous version in which this bug was not present was
No response
Description
If angular is used with "@angular/localize" and two languages, the build is split into "en" and "de". Now if a image image is linked in a stylesheet with an absolute url (e.g. "background-image: url('/https/github.com/assets/1.jpg');", this works in development, but once the application is deployed, the image is not found because the assets folder is not located in the root directory.
Not using a "/" at the beginning, causes the following error
X [ERROR] Could not resolve "assets/1.jpg" [plugin angular-css-resource]
src/app/pages/startpage/intro/intro.component.scss:11:24:
11 │ background-image: url("assets/1.jpg");
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "assets/intro/intro-minimal.jpg" as external to exclude it from the bundle, which will remove this error and leave the unresolved path in the bundle.
Preprocessor stylesheets may not show the exact file location of the error.
Using a "~", or "./", etc causes similar build issues. Using relative paths is it's own can of worms and also does not work out of the box...
Absolute paths are not handled by the build system. Currently, there is no way to output assets directly to the root directory or maintain a single copy.
However, relative paths are supported, as files are fingerprinted (hashed) and copied for each locale and works out of the box. Can you please elaborate on what is the problem with relative paths?
In the past I made really bad experiences with relative paths, when it comes to refactoring, however I must say that the now this seems to be very nicely. As far as I read into it, it was just added with angular 17, so I kinda missed it but again, very nice :)
However that leaves the folder build structure i18n interacting very poorly with those absolute urls. So maybe revisit #26286
Command
build, other
Is this a regression?
The previous version in which this bug was not present was
No response
Description
If angular is used with "@angular/localize" and two languages, the build is split into "en" and "de". Now if a image image is linked in a stylesheet with an absolute url (e.g. "background-image: url('/https/github.com/assets/1.jpg');", this works in development, but once the application is deployed, the image is not found because the assets folder is not located in the root directory.
Not using a "/" at the beginning, causes the following error
Using a "~", or "./", etc causes similar build issues. Using relative paths is it's own can of worms and also does not work out of the box...
Minimal Reproduction
.sample-class {
background-image: url('/https/github.com/assets/1.jpg');
]
Exception or Error
Your Environment
Anything else relevant?
#26286
could resolve it.
The text was updated successfully, but these errors were encountered: