-
-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Open
Labels
Description
Describe the bug
Dev mode in a react server-rendered application, the initial critical css is not inlined into the html.
Styles kicks in only after the react hydration and the vite runtime loaded.
This results in a very bad flickering, especially in big applications since it takes a few seconds before the vite fetches all the required js and is browser ready.
Expectation
The stylesheet with critical css is either:
- inlined in the html
or - is written to the build folder so that its at least possible to inline that css file in the react ssr handler with some custom logic.
Reproduction
https://github.com/chin2km/vite-react-ssr-dev-mode-critical-css-issue
Steps to reproduce
yarn dev
and see the flickering from the server rendered page goes from a no-styles state to when the styles are loaded.
System Info
System:
OS: macOS 14.1
CPU: (10) arm64 Apple M1 Pro
Memory: 1.72 GB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.0.0 - ~/.nodenv/versions/20.0.0/bin/node
Yarn: 1.22.22 - ~/.nodenv/versions/20.0.0/bin/yarn
npm: 7.24.2 - ~/Documents/AboutYou/tadarida-frontend-web/node_modules/.bin/npm
pnpm: 8.15.6 - ~/.nodenv/versions/20.0.0/bin/pnpm
bun: 0.1.10 - ~/.bun/bin/bun
Browsers:
Chrome: 124.0.6367.62
Safari: 17.1Used Package Manager
yarn
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
uorhsohk, simoncarbajal, mattkindy, uap-dev, Splines and 1 moresegmentationfaulter and Splines