sassc-rails icon indicating copy to clipboard operation
sassc-rails copied to clipboard

Glob Imports Not Working (Workaround Found)

Open D40298008 opened this issue 4 years ago • 0 comments

I am in the process of upgrading an older Ruby / Rails application to the latest dependencies. When I swapped out sass-rails 5.1.0 to sassc-rails 2.1.2, I encountered a really strange bug. I found a workaround but I figure this could help someone else

Also, I'm not entirely sure if the bug is on Rails (6.0.3.4) or Sprockets (4.0.2) or SassC-Rails (2.1.2) or if I missed some documentation somewhere, but here is a simplified setup describing the issue:

Folder structure for /app/assets/stylesheets/:

- admin.js.erb    <-- (this is precompiled in manifest.js)
- admin/
    - _main.scss
    - _menu.scss

Contents of admin.js.erb:

@import "admin/*";

Include statement in admin.html.erb:

<%= stylesheet_link_tag "admin" %>

This usage of the glob import will cause the following error: Screen Shot 2020-10-16 at 12 56 37 PM

In order to fix this, I have to either import everything in the admin folder one by one ... or change my stylesheet link call to this:

<%= stylesheet_link_tag asset_path("admin.css") %>

D40298008 avatar Oct 16 '20 22:10 D40298008