Skip to content

Fix Madmin importmap assets with Propshaft - #343

Open
elalemanyo wants to merge 2 commits into
excid3:mainfrom
elalemanyo:fix/propshaft-importmap-assets
Open

Fix Madmin importmap assets with Propshaft#343
elalemanyo wants to merge 2 commits into
excid3:mainfrom
elalemanyo:fix/propshaft-importmap-assets

Conversation

@elalemanyo

@elalemanyo elalemanyo commented Jul 14, 2026

Copy link
Copy Markdown

I hope this wasn't just an issue on my machine, but I ran into broken local asset URLs in the dummy app and traced it back to Propshaft not being loaded before the engine booted.

Summary

  • require propshaft before booting the engine so importmap asset paths resolve correctly
  • restore Madmin's JavaScript and stylesheet asset loading in the dummy app
  • add an integration test covering resolved asset URLs on /madmin

Problem

The dummy app rendered importmap tags, but local asset URLs were unresolved and fell back to broken paths like:

  • /madmin/application.js
  • /turbo.min.js
  • /stylesheets/dummy.css

That left Madmin with missing JavaScript and CSS in development.

Fix

Load propshaft before madmin/engine so the asset server is available when importmap and stylesheet helpers resolve Madmin assets.

@excid3

excid3 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

I haven't seen this and I use propshaft.

Create a new Rails application to that reproduces the issue so we can see what exactly causes it if there is a load order issue somewhere. And please share the exact error(s) you were seeing.

Also Madmin works with sprockets, so we can't merge a change like this. If you want to run the tests against sprockets, use the appraisal:
https://github.com/excid3/madmin/blob/main/Appraisals#L40-L43

@elalemanyo

elalemanyo commented Jul 14, 2026

Copy link
Copy Markdown
Author

@excid3 Here’s what I did locally to run the app.
Because this repo is a Rails engine, I used the bundled dummy app in test/dummy rather than a separate host app.

From the repo root:

bundle install
bundle exec bin/rails db:create
bundle exec bin/rails server -p 3000

Then I opened the app. The page rendered, but none of the local JavaScript loaded, and the browser console showed 404s for the asset URLs generated by the page:

  • GET /madmin/application.js -> 404
  • GET /turbo.min.js -> 404
  • GET /stimulus.min.js -> 404
  • GET /stimulus-loading.js -> 404
  • GET /actiontext.esm.js -> 404
  • GET /activestorage.esm.js -> 404
  • GET /trix.js -> 404
  • GET /madmin/controllers/application.js -> 404
  • GET /madmin/controllers/index.js -> 404
  • GET /madmin/controllers/mobile_nav_controller.js -> 404
  • GET /madmin/controllers/nested_form_controller.js -> 404
  • GET /madmin/controllers/select_controller.js -> 404
  • GET /stylesheets/dummy.css -> 404

So /madmin itself returned 200 and rendered HTML, but the importmap/local asset URLs in that page were unresolved, which left the admin UI without working JS.

Sorry, maybe I'm doing something wrong, and that's why it's not working 🙏

@excid3

excid3 commented Jul 14, 2026

Copy link
Copy Markdown
Owner

I just pushed a couple small clean up things.

I confirmed it works fine with both propshaft and sprockets in our test suite dummy app. You can clone the repo, bundle, and run rails server to see.

Your Gemfile needs to require either one so that Rails.app.config.assets is present when the engines are executed by Rails. You might have require: false or something that should be removed.

source "https://rubygems.org"

gem "rails", "~> 8.1.3"
gem "propshaft"

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.

2 participants