Composable asset pipeline with pluggable bundler support - #7
Merged
Merged
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|none` (default: esbuild)
- `--lang=js|ts` (default: js)
- `--tailwind/--no-tailwind` (default: true)
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.tailwind` — app.css, dynamically composes
bundler-specific runner via `phx.install.assets.tailwind.#{bundler}`
- `phx.install.assets.tailwind.esbuild` — tailwind hex package 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.
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 subtasks--lang=tsoption for TypeScript entry point generationphx.install.assets.tailwind.#{bundler}), so adding a new bundler requires no changes to existing filesNew flags on
phx.install.assets--bundleresbuild,noneesbuild--langjs,tsjs--tailwindtrueTask composition
Extensibility
Adding support for a new bundler (e.g. from an external package) requires implementing two tasks:
phx.install.assets.<bundler_name>— JS bundling setupphx.install.assets.tailwind.<bundler_name>— Tailwind CSS runner for that bundlerNo changes to existing files needed.
Test plan
--no-tailwind,--lang ts,--bundler none, custom app name, idempotencymix format --check-formattedpasses