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).
This commit is contained in:
Masen Furer 2025-02-06 11:16:48 -08:00
parent a944a34e63
commit 8e3962426e
No known key found for this signature in database
GPG Key ID: B0008AD22B3B3A95

View File

@ -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