Skip to content

feat: configurable assets_dir and lockfile_dir for apps sharing a project root - #8009

Open
benedikt-bartscher wants to merge 11 commits into
reflex-dev:mainfrom
benedikt-bartscher:app-assets-and-lockfile-dirs
Open

benedikt-bartscher wants to merge 11 commits into
reflex-dev:mainfrom
benedikt-bartscher:app-assets-and-lockfile-dirs

Conversation

@benedikt-bartscher

@benedikt-bartscher benedikt-bartscher commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

An app always takes its static files from <root>/assets and persists its frontend package.json and lockfiles in <root>/reflex.lock. Two apps that share a project root, say a dashboard and a static marketing site built from the same repo, each with its own config, therefore step on each other:

  • every build copies the whole assets/ into its frontend, so the small site ships the dashboard's assets (22 MB in our case);
  • every install rewrites reflex.lock/, so building the site replaces the dashboard's committed lockfile with the site's smaller package set, and the next dashboard build changes it back.

.web can already move per app with REFLEX_WEB_WORKDIR; these two directories could not. This PR adds two config fields:

config = rx.Config(
    app_name="website",
    assets_dir=Path("website/assets"),
    lockfile_dir=Path("website/reflex.lock"),
)

Both are relative to the app root (absolute paths work too), default to assets and reflex.lock, take strings as well, and can come from REFLEX_ASSETS_DIR / REFLEX_LOCKFILE_DIR like any config field. assets_dir is used wherever the assets directory was hardcoded: the copy into .web/public, rx.asset (local files and the external/ links of shared ones), local stylesheets in App(stylesheets=...), and reflex rename. lockfile_dir goes through frontend_skeleton.get_root_lockfile_dir(), which the lockfile sync, the npm detection and its messages, the hot reload exclusion and telemetry now use. Nothing changes for an app that sets neither.

This touches the same lines of _compile_root_stylesheet as #8007 (page stylesheets), which moves them into helpers; whichever merges second resolves the conflict by reading get_config().assets_dir in those helpers.

View guided diff

@FarhanAliRaza FarhanAliRaza added documentation Improvements or additions to documentation enhancement Anything you want improved labels Nov 25, 2026 — with ChatGPT Codex Connector
@greptile-apps

greptile-apps Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Adds assets_dir and lockfile_dir so apps sharing a project root can keep separate assets and frontend lockfiles.

  • Apps can choose which folder supplies their static files.
  • Apps can save frontend package files in separate folders.
  • Renaming an app keeps configured folders pointed at their new location.

Reviews (6) · Last reviewed commit: "fix: update absolute directory settings ..." · Reviewed by Greptile

Comment thread reflex/utils/rename.py Resolved
Comment thread reflex/utils/exec.py Resolved
Comment thread reflex/assets.py Resolved
@codspeed

codspeed Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

1 warning

⚠️ 16 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 146 untouched benchmarks
⏩ 8 skipped benchmarks1


Comparing benedikt-bartscher:app-assets-and-lockfile-dirs (57051a9) with main (6f5c39c)

Open in CodSpeed

Footnotes

  1. 8 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@benedikt-bartscher
benedikt-bartscher marked this pull request as ready for review November 26, 2026 08:49
@benedikt-bartscher
benedikt-bartscher requested a review from a team as a code owner November 26, 2026 08:49

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed against the latest diff

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread tests/units/test_config.py Resolved
Comment thread reflex/utils/rename.py Resolved
Comment thread reflex/utils/rename.py Resolved
Comment thread tests/units/test_prerequisites.py Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread reflex/utils/rename.py Resolved
Comment thread reflex/utils/rename.py Resolved

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread reflex/utils/rename.py Resolved

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement Anything you want improved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants