You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #51 [Builds] Add support for multiple named builds (Kocal)
This PR was merged into the main branch.
Discussion
----------
[Builds] Add support for multiple named builds
| Q | A
| -------------- | ---
| Bug fix? | no
| New feature? | yes
| Deprecations? | no
| Documentation? | yes
| License | MIT
This is Reprise's port of Webpack Encore's multi-build feature (Encore's `builds` config plus the `entrypointName` argument on tag functions). A single Symfony app can now drive several independent bundles at once: for example, a Vite-built public frontend and an Rsbuild-built admin panel, each with its own plugin config, output directory, and `entrypoints.json`. The default build continues to come from `output_path`; named builds are declared under a new `builds` key (a map of build name -> output directory). Setting `output_path: false` enables a named-builds-only setup, provided at least one build is declared (the bundle throws at container-compile time otherwise). The name `_default` is reserved.
Every Twig tag and file function (`reprise_entry_script_tags`, `reprise_entry_link_tags`, `reprise_entry_js_files`, `reprise_entry_css_files`) and `reprise_entry_exists` now accepts a `build` argument to select which build to look up; omitting it falls back to the default.
```twig
{{ reprise_entry_script_tags('app') }}
{{ reprise_entry_script_tags('dashboard', build='admin') }}
```
A few internals worth flagging for review: there is a new `EntrypointsLookupCollection` (backed by a service locator, behind a public `EntrypointsLookupCollectionInterface`) that resolves the per-build `EntrypointsLookup` service on demand, and a new `UndefinedBuildException` for unknown build names. The `TagRenderer` now resolves its lookup through that collection and tracks injected HMR clients as a set keyed by client URL, so two dev servers running simultaneously (Vite and Rsbuild) each inject their client exactly once. The reset listener was generalized to reset an `iterable<ResetInterface>` covering every build's lookup plus the renderer, and the cache warmer now warms one cache key per build. The `build` argument on Twig functions, previously introduced as a reserved placeholder that threw on use, is now fully functional.
No JS or plugin changes are needed: one bundler config already writes one `entrypoints.json` per output directory. The feature is covered by unit tests, a Vite+Rsbuild functional test, and config-validation tests, and documented in `doc/index.rst`.
Commits
-------
afb5bfa [Builds] Add support for multiple named builds
0 commit comments