add option to disable hmr#5745
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR adds the ability to disable Hot Module Replacement (HMR) in Vite through a new environment variable VITE_HMR. The changes span three files to implement this feature:
-
Environment Configuration (
reflex/environment.py): Adds a new boolean environment variableVITE_HMRthat defaults toTrue, maintaining backward compatibility while allowing users to disable HMR by settingVITE_HMR=false. -
Frontend Skeleton (
reflex/utils/frontend_skeleton.py): Updates the_compile_vite_configfunction to read theVITE_HMRenvironment variable and pass it to the Vite configuration template. -
Template System (
reflex/compiler/templates.py): Modifies thevite_config_templatefunction to accept anhmrboolean parameter and outputs the appropriate JavaScript boolean value in the generatedvite.config.jsfile.
This change follows Reflex's established pattern of using environment variables for development-time configuration. It integrates cleanly with the existing template system and allows developers to control HMR behavior without code modifications. The feature is particularly useful for debugging scenarios, performance testing, or when working with libraries that don't support HMR (such as WebAssembly modules).
Confidence score: 4/5
- This PR is safe to merge with low risk as it's a simple configuration addition
- Score reflects straightforward implementation following established patterns with minimal surface area for bugs
- Pay close attention to the template rendering logic in
reflex/compiler/templates.pyto ensure proper JavaScript boolean output
3 files reviewed, 1 comment
| }}, | ||
| }}, | ||
| }}, | ||
| hmr: {"true" if hmr else "false"}, |
There was a problem hiding this comment.
logic: The hmr field placement in the Vite config structure seems incorrect. In Vite, HMR is typically configured under server.hmr, not as a top-level property.
CodSpeed Performance ReportMerging #5745 will not alter performanceComparing Summary
|
| reactRouter(), | ||
| safariCacheBustPlugin(), | ||
| ], | ||
| ].concat({"[fullReload()]" if force_full_reload else "[]"}), |
There was a problem hiding this comment.
why concat and not just {"fullReload()" if force_full_reload else ""} in the plugins list?
There was a problem hiding this comment.
not a strong reason i just wanted it to be at least in theory extendable but it's not different either way
No description provided.