Serve bundled assets from the engine (no asset pipeline required) - #1
Merged
Merged
Conversation
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
marked this pull request as ready for review
July 20, 2026 05:04
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.
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 inconfig.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 correctContent-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).blazer-assets/*path→assets#show(helperblazer.asset_file_path), so URLs are correct wherever the engine is mounted.<link>/<script>tags (withnonce) 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.cssglyphicon font URLs made relative so they resolve through the same controller.config.assets.precompileblock removed from the engine initializer.Notes for reviewers
Testing
test/assets_test.rbcovers: JS/CSS/nested/font/favicon served with correct content types, 404 for missing paths, path-traversal rejection, and that a rendered page referencesblazer-assets/*(and not a host pipeline).masterbaseline (identical pre-existing failures/errors; the 8 new asset tests all pass).🤖 Generated with Claude Code