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
- Install Rails Admin: Add
gem 'rails_admin'to your Gemfile and runbundle install. - Set up Importmap according to Rails 7 documentation.
- Run the Rails Admin installation generator:
rails g rails_admin:install. - Start the Rails server:
rails s. - Navigate to
/adminto 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