How to preload stylesheet in development mode? #81
-
With vite, it seems all styles are added as inline css after the chunk is loaded. Is there any way, I could preload some stylesheets? What I want is to display a loader until the page is completely loaded. I am trying to use bootstrap 4's progress bar. I'm using https://github.com/ElMassimo/jumpstart-vite to create the project. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hi Prios! This could be related to #48, in the sense that Vite will only inject CSS that way during development, but in production the stylesheet would be preloaded instead. You could try shutting down the Vite development server temporarily while developing the progress bar feature. This will cause assets to be compiled and to load as the would in production, the only downside is that it would rebuild every time you change assets. Another option would be to use |
Beta Was this translation helpful? Give feedback.
Hi Prios!
This could be related to #48, in the sense that Vite will only inject CSS that way during development, but in production the stylesheet would be preloaded instead.
You could try shutting down the Vite development server temporarily while developing the progress bar feature. This will cause assets to be compiled and to load as the would in production, the only downside is that it would rebuild every time you change assets.
Another option would be to use
vite_stylesheet_tag
to render alink
tag instead, and create a separate stylesheet that contains the styles you need for the progress bar.