1

Using Rails 3 Asset Pipeline, I am importing mixins using

@import "mixins.css.scss";

in to a main SCSS file. Then utilize via

@include big_box(34px);

The problem is that when I make changes to the mixin in the separate file, the changes to take effect until I go into the main SCSS file, do any change (even a white space) and save.

There must be a way to disable mixin caching in the development environment to avoid this annoying step. I haven't been able to find the answer on my own.

NOTE: I'm using RubyMine for IDE

Artem K.
  • 804
  • 6
  • 15

2 Answers2

1

This isn't default behavior. However, I wonder if the problem is in how you're specifying the import.

Is the filename of the mixin actually, mixins.css.scss? If so, I recommend trying the partial-like naming convention that may actually be SCSS's preferred way: rename the file to _mixins.css.scss and in your manifest file specify @import 'mixins'.

This method reloads changes in all files for me as expected.

Eric
  • 2,539
  • 18
  • 23
  • The file is `_mixins.css.scss`. When I try importing without the file extensions I get an error: `File to import not found or unreadable: mixins.` – Artem K. Jan 27 '15 at 21:56
  • The mixin file is in the same directory as the SCSS file that imports it. The manifest is one level up from both and requires the entire directory where these files are located. – Artem K. Jan 27 '15 at 22:09
  • Ah, that might be your problem. I would just import everything straight from the manifest instead of nesting your imports. This also works better if you remove `require_tree` or anything like that. Just list everything at the top. – Eric Jan 27 '15 at 23:11
  • You're suggesting I stop using @import for CSS mixins and instead require the file with mixins in the manifest? Goes a bit against [this example](http://stackoverflow.com/questions/8887824/persisting-scss-variables-in-rails-asset-pipeline) and with experiments I can't access mixins that are not imported – Artem K. Jan 28 '15 at 00:33
  • No, I mean remove `* require...` style lines unless necessary and use `@import` for everything. – Eric Jan 28 '15 at 00:59
  • The use of require doesn't seem to be a problem. It's the use of @import actually for mixins and the problem occurs regardless of the level of nesting. – Artem K. Feb 16 '15 at 04:37
  • After upgrading to Rails 4 (4.2) there's no more issues with cached mixins. SCSS files properly reflect mixins updates in separate files. – Artem K. May 08 '15 at 17:17
0

@Eric is correct, just a few notes for clarity....

  • Rename imported Sass with an underscore: _mixins.css.scss
  • @import without the underscore and without the file extension
  • Note, you can include paths...

E.g.

For path/to/_buttons.css.scss

@import 'path/to/buttons'

Rails will bust that cache whenever you edit _buttons.css.scss

(Note, I'm on Rails 4.2)
Hari Honor
  • 8,677
  • 8
  • 51
  • 54