← Graph

Pre-Compile Engine Assets at Build Time

concept 5 connections

Asset-pipeline strategy for packaged Rails engines. Instead of hooking into the host app's asset pipeline (which forces host apps to have Node.js, esbuild, etc. at deploy time), the engine runs esbuild and Tailwind at gem build time, writing compiled output into `public/<engine>-assets/`. A `Rack::Static` middleware registered in the engine class maps the public path to those files so the host app serves them transparently. The engine's application layout picks compiled vs in-development assets via an 'is packed?' check.

category
pattern
about
Pre-Compile Engine Assets at Build Time concept
Final section of the talk explains compiling engine assets at build time.
about
Pre-Compile Engine Assets at Build Time concept
The takeaway names and recommends this pattern.
concept Pre-Compile Engine Assets at Build Time
related_to
The pattern uses Rack::Static middleware to serve the pre-compiled asset directory from the engine.
concept Pre-Compile Engine Assets at Build Time
related_to
esbuild tool
esbuild compiles JavaScript as part of the build-time asset pipeline.
concept Pre-Compile Engine Assets at Build Time
related_to
Tailwind compiles CSS as part of the build-time asset pipeline.

Provenance

Read by
8 extractions