Conversation
Refactor `phx.install.assets` from a monolithic task into a composable
orchestrator with pluggable bundler and CSS runner subtasks.
New flags on `phx.install.assets`:
- `--bundler=esbuild|bun` (default: esbuild)
- `--lang=js|ts` (default: js)
- `--tailwind/--no-tailwind` (default: true)
- `--js-test/--no-js-test` (default: false, bun only)
New subtasks:
- `phx.install.assets.static` — robots.txt + favicon
- `phx.install.assets.live_reload` — live_reload config in dev.exs
- `phx.install.assets.esbuild` — esbuild hex dep, app.js/ts, vendored topbar
- `phx.install.assets.bun` — bun hex dep, app.js/ts, package.json with
workspace deps + npm packages (topbar, tailwindcss)
- `phx.install.assets.tailwind` — app.css, dynamically composes
bundler-specific runner via `phx.install.assets.tailwind.#{bundler}`
- `phx.install.assets.tailwind.esbuild` — tailwind hex package runner
- `phx.install.assets.tailwind.bun` — bun css profile runner
Adding support for a new bundler requires implementing two tasks
(`phx.install.assets.<name>` and `phx.install.assets.tailwind.<name>`)
with no changes to existing files.
I'm not 100% sure, but I used file:{path} dependencies with phoenix_vite and it made bun fetch and use devDependencies of the packages under ../deps - which is generally not what you want. I only notices it because I installed playwright for phoenix_test and it never used the latest version I needed. Turns out live_view uses playwright as a dev dependency and I always got their version. |
|
See LostKobrakai/phoenix_vite#21 for small amouts of context :D |
Collaborator
Author
|
Superseded — composable architecture extracted without bun support into a separate PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
phx.install.assetsfrom a monolithic task into a composable orchestrator with pluggable bundler and CSS runner subtasksbunhex package — npm workspace deps instead of vendored JS, bun profiles for JS and CSS--lang=tsoption for both bundlers, generating a well-factored TypeScript entry pointphx.install.assets.tailwind.#{bundler}), so adding a new bundler requires no changes to existing filesNew flags on
phx.install.assets--bundleresbuild,bunesbuild--langjs,tsjs--tailwindtrue--js-testfalseTask composition
Test plan
--no-tailwind,--lang ts,--bundler bun,--bundler bun --lang ts,--js-testopt-in and default-offmix phx.install.assets --bundler bun --lang tsin a fresh project