Home > Blockchain >  Preload css in angular 15
Preload css in angular 15

Time:01-31

I'm crating application in angular with SSR

How do I apply <link rel="preload" href="/styles.css" as="style" /> to head section or Link header in order to preload/prefetch whole styles.css file?

Using plain styles.css is not enoug as production build generate file that contains random characters like styles.7541caaaab536370.css (different in every build)

Googling about preloading and prefetching in angular only results in preloading components/modules and I'm out of ideas

CodePudding user response:

You can include the styles.css file in the assets folder. This will prevent the angular build process from "fingerprinting" the file and the resulting build file will simply be named styles.css allowing you to reference it directly from your index.html.

  • Related