From 8e3962426e2f8290e09548b60063c7310c718d1d Mon Sep 17 00:00:00 2001 From: Masen Furer Date: Thu, 6 Feb 2025 11:16:48 -0800 Subject: [PATCH] Update assets tree as app._compile step. If the assets change between hot reload, then update them before reloading (in case a CSS file was added or something). --- reflex/app.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/reflex/app.py b/reflex/app.py index a3d0d8e10..ae2e6044f 100644 --- a/reflex/app.py +++ b/reflex/app.py @@ -99,7 +99,15 @@ from reflex.state import ( _substate_key, code_uses_state_contexts, ) -from reflex.utils import codespaces, console, exceptions, format, prerequisites, types +from reflex.utils import ( + codespaces, + console, + exceptions, + format, + path_ops, + prerequisites, + types, +) from reflex.utils.exec import is_prod_mode, is_testing_env from reflex.utils.imports import ImportVar @@ -1008,7 +1016,7 @@ class App(MiddlewareMixin, LifespanMixin): ) # try to be somewhat accurate - but still not 100% - adhoc_steps_without_executor = 7 + adhoc_steps_without_executor = 8 fixed_pages_within_executor = 5 progress.start() task = progress.add_task( @@ -1086,6 +1094,14 @@ class App(MiddlewareMixin, LifespanMixin): progress.advance(task) + # Copy the assets. + with console.timing("Copy assets"): + path_ops.update_directory_tree( + src=Path.cwd() / constants.Dirs.APP_ASSETS, + dest=Path.cwd() / prerequisites.get_web_dir() / constants.Dirs.PUBLIC, + ) + progress.advance(task) + # Use a forking process pool, if possible. Much faster, especially for large sites. # Fallback to ThreadPoolExecutor as something that will always work. executor = None