Skip to content

Commit 5cf2517

Browse files
committed
add both options
1 parent b9d9bf7 commit 5cf2517

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

reflex/compiler/templates.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,12 +502,13 @@ def package_json_template(
502502
)
503503

504504

505-
def vite_config_template(base: str, hmr: bool):
505+
def vite_config_template(base: str, hmr: bool, force_full_reload: bool):
506506
"""Template for vite.config.js.
507507
508508
Args:
509509
base: The base path for the Vite config.
510510
hmr: Whether to enable hot module replacement.
511+
force_full_reload: Whether to force a full reload on changes.
511512
512513
Returns:
513514
Rendered vite.config.js content as string.
@@ -556,7 +557,7 @@ def vite_config_template(base: str, hmr: bool):
556557
alwaysUseReactDomServerNode(),
557558
reactRouter(),
558559
safariCacheBustPlugin(),
559-
].concat({"[fullReload()]" if not hmr else "[]"}),
560+
].concat({"[fullReload()]" if force_full_reload else "[]"}),
560561
build: {{
561562
assetsDir: "{base}assets".slice(1),
562563
rollupOptions: {{
@@ -578,6 +579,7 @@ def vite_config_template(base: str, hmr: bool):
578579
}},
579580
server: {{
580581
port: process.env.PORT,
582+
hmr: {"true" if hmr else "false"},
581583
watch: {{
582584
ignored: [
583585
"**/.web/backend/**",

reflex/environment.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,9 +640,12 @@ class EnvironmentVariables:
640640
# Enable full logging of debug messages to reflex user directory.
641641
REFLEX_ENABLE_FULL_LOGGING: EnvVar[bool] = env_var(False)
642642

643-
# Whether to enable hot module replacement.
643+
# Whether to enable hot module replacement
644644
VITE_HMR: EnvVar[bool] = env_var(True)
645645

646+
# Whether to force a full reload on changes.
647+
VITE_FORCE_FULL_RELOAD: EnvVar[bool] = env_var(False)
648+
646649

647650
environment = EnvironmentVariables()
648651

reflex/utils/frontend_skeleton.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,11 @@ def _compile_vite_config(config: Config):
193193
base = "/"
194194
if frontend_path := config.frontend_path.strip("/"):
195195
base += frontend_path + "/"
196-
return templates.vite_config_template(base=base, hmr=environment.VITE_HMR.get())
196+
return templates.vite_config_template(
197+
base=base,
198+
hmr=environment.VITE_HMR.get(),
199+
force_full_reload=environment.VITE_FORCE_FULL_RELOAD.get(),
200+
)
197201

198202

199203
def initialize_vite_config():

0 commit comments

Comments
 (0)