Skip to content

Serve bundled assets from the engine (no asset pipeline required) - #1

Merged
gabrieltaylor merged 1 commit into
masterfrom
claude/blazer-no-asset-pipeline-20f2c2
Jul 20, 2026
Merged

Serve bundled assets from the engine (no asset pipeline required)#1
gabrieltaylor merged 1 commit into
masterfrom
claude/blazer-no-asset-pipeline-20f2c2

Conversation

@gabrieltaylor

Copy link
Copy Markdown
Collaborator

What

Makes Blazer serve its own bundled JS/CSS/fonts directly from the engine, so it works in a host Rails app that has no asset pipeline (neither Sprockets nor Propshaft).

Why

Blazer currently relies on the host app's asset pipeline to serve its assets — the layout branches on Propshaft vs. Sprockets and calls stylesheet_link_tag / javascript_include_tag / favicon_link_tag, and the engine registers everything in config.assets.precompile. In an app with no asset pipeline at all, those helpers produce unusable paths and no asset is served, so Blazer renders unstyled and non-functional.

How

  • Blazer::AssetsController (new) serves the already-vendored assets from the engine with the correct Content-Type, long-lived cache headers, and a path-traversal guard. It's a public, GET-only endpoint, so CSRF and the cross-origin-JavaScript check are disabled (both would otherwise block embedding the served JS).
  • Route blazer-assets/*pathassets#show (helper blazer.asset_file_path), so URLs are correct wherever the engine is mounted.
  • Layout rewritten to emit plain <link> / <script> tags (with nonce) in place of the pipeline branching, referencing the same current asset set (Tom Select, tablesort, Ace, Chart.js, etc.). Favicon uses a plain <link rel="icon">.
  • bootstrap-propshaft.css glyphicon font URLs made relative so they resolve through the same controller.
  • config.assets.precompile block removed from the engine initializer.

Notes for reviewers

  • Single self-contained code path replaces the Propshaft/Sprockets branching. Hosts that do have a pipeline still work — the assets are just served by the engine instead.
  • No new runtime dependencies, no CDN.
  • The asset content itself is unchanged; only the delivery mechanism (engine route vs. host pipeline) changed.

Testing

  • New test/assets_test.rb covers: JS/CSS/nested/font/favicon served with correct content types, 404 for missing paths, path-traversal rejection, and that a rendered page references blazer-assets/* (and not a host pipeline).
  • Full suite run on SQLite shows no regressions vs. a clean master baseline (identical pre-existing failures/errors; the 8 new asset tests all pass).

🤖 Generated with Claude Code

Blazer relied on the host app's asset pipeline (Sprockets or Propshaft)
to serve its JS/CSS. Serve the vendored assets directly from the engine
instead, so Blazer works with no asset pipeline at all.

- Add Blazer::AssetsController serving allowlisted vendored JS/CSS/fonts
  with correct content types, long cache headers, and a traversal guard
- Add blazer-assets/*path route (blazer.asset_file_path helper)
- Rewrite the layout to emit plain link/script tags (no pipeline branching)
- Make bootstrap-propshaft.css glyphicon font URLs relative
- Drop config.assets.precompile from the engine initializer

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@gabrieltaylor
gabrieltaylor marked this pull request as ready for review July 20, 2026 05:04
@gabrieltaylor
gabrieltaylor merged commit 6744c16 into master Jul 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant