-
Notifications
You must be signed in to change notification settings - Fork 12k
Assets, base href and relative urls in css/scss #17747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, To follow up on some points mentioned in #14587 (comment)
You can use
You can choose not to hash such files, using the
This is indeed a bug and is being tracked #12186 Now, back to the your issue, currently there is no supported way to disable relative images referenced in css from being copy, however it's still fairly simple to achieve what you want.
|
Additionally, I'd personally would avoid to go with the above approach from the start to lazy load an image. IMHO, a more clean, non coupled and re-usable approach would be to create a directive that:
And if you are looking to improve the performance even further can can use |
Closing as the above explanations should suffice. If the problem persists please open a new issue with a reproduction. Thanks. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
First of all, my project has multiple localizations defined in angular.json, so when running
ng build --configuration=production --localize
there are 3 subdirectories created in
dist
output path. Each of them has different base href in their index.html file.Second, in angular.json I have assets subsection defined like:
and in assets/images there are these image files (among others):
Then I have a component in some nested directory within the project, that is using following css classes:
As you can see, I am using root path to assets folder (starting with '/'), which is obviously wrong for base href that is not '/'.
My goal is to have div initialized with blured version of image, which is later replaced by full version. This is how I am doing it:
Template:
Typescript:
This is ok during local development when running
ng serve
without base href parameter:If I run
ng serve --base-href /de/
, which simulates run from production environment on IIS:Ok: let's switch to relative paths in .css url path, as advised in #4778 (comment):
On local development without base href it is working fine, as well as with --base-href /de/.
BUT what this causes when building? The files used in relative paths are copied from /assets/images/ to root directory of each localized build. This is unwanted and inpractical for many reasons described e.g. here: #14587 (comment) !!!
Side effect of this solution is:
Other solutions that I tried:
I am searching for a clean solution which:
Unfortunately, many of similar issues here on git are already locked due to inactivity, that's why I am creating this new one.
🌍 Your Environment
The text was updated successfully, but these errors were encountered: