Rails 7 with Importmap: Rails Admin SCSS :- unreadable: @import rails_admin/src/rails_admin/styles/base. Fix Using Yarn/NPM

Author: princetechsCreated May 30, 2024Updated Mar 20, 2025

Describe the bug Integrating Rails Admin in a Rails 7 environment with Importmap and asset management via Yarn or NPM leads to an issue where the rails_admin.scss does not compile correctly. The styles are not applied as expected, indicating that the asset pipeline may not be properly importing styles from the specified SCSS path.

Reproduction Steps

  1. Install Rails Admin: Add gem 'rails_admin' to your Gemfile and run bundle install.
  2. Set up Importmap according to Rails 7 documentation.
  3. Run the Rails Admin installation generator: rails g rails_admin:install.
  4. Start the Rails server: rails s.
  5. Navigate to /admin to observe the styling issue.

Expected Behavior Navigating to the /admin route should display the Rails Admin interface styled correctly, showcasing a fully functional and visually appealing UI consistent with Rails Admin standards.

Additional Context

  • Rails version: 7.0
  • Rails Admin version: 3.1.2

Source: railsadminteam/rails_admin