-
Notifications
You must be signed in to change notification settings - Fork 12k
Way to load additional css files with hash in filename after app init. #23362
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
Would dynamically querying the file names help? const darkCSS = document.querySelector('link[rel="stylesheet"][href^="dark"]').href; |
I don't think so. Check the service i wrote. It is important to give people the possibility to overwrite the OS specific selected prefered-color-scheme by writing it into the localStorage. First we have to check the result of the service, THEN we have to load (depends on the result) the light or dark theme. (Which filename we don't have) Maybe something like a env.cache makes sense that gets generated while build task, where the filenames get stored... But I think this will anoy alot people only for prefered-color stuff... |
Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends. Find more details about Angular's feature request process in our documentation. |
Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage. We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package. You can find more details about the feature request process in our documentation. |
Hi @SvenBudak, Can you elaborate why using the inject option would break PWA support? |
Because the Angular Serviceworker needs the hashes in the filenames to understand when a file has updated: https://angular.io/guide/service-worker-communications#version-updates I updated the Topic and added this information. |
@SvenBudak, the service-worker doesn't need filename with hashes to understand when a file has been updated as it relies on the content hashes. In the linked document it is also mentioned that in some cases using filenames with hashes can cause unrecoverable states. More information about this can be read https://angular.io/guide/service-worker-devops#service-worker-and-caching-of-app-resources |
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. |
I am working on a good solution for dark / light theming depends on
prefers-color-scheme
. This is what i got: https://medium.com/@svenbudak/how-to-implement-dark-light-mode-in-angular-mateiral-with-prefers-color-scheme-ce3e980e2ea5The problem in this solution is that both themes are includet inside the app. Which can be cool, because if there are just some some little lines they overwrite some basic colors, there will be no loading time while switching theme. But if there are some more lines of theming css, its overhead to load both.
So i added to angular.json:
Which is working very well. It generates me this 2 files:
I also asked in the
@angular/components
issue board, but i think this is a angular task.I know i can add in the angular.json the
inject
attribute, then they have no hashes and i can load them easy with renderer2. But then the PWA support will gets lost. (Because the Angular Serviceworker needs the hashes in the filenames to understand when a file has updated: https://angular.io/guide/service-worker-communications#version-updates) They are any plans to make it possible to get somehow filenames like this after the app gets initialized? Because i need to check in app first theprefers-color-scheme
(i will make this check in js file, because i do some more then only read it from browser).The text was updated successfully, but these errors were encountered: