2

I am trying to convert from sass-rails to sassc-rails. I am using rails 4.2.2.

When I use sassc-rails, changes to my scss files are not being reflected in the view, even if I stop and restart the server (I have turned off spring). If I stop the server and do a rm -r tmp/cache/assets, the changes are reflected.

If I go back to sass-rails it works properly, though I have to do a rm -r tmp/cache/assets before I restart the server to have it working properly.

How do I fix this?

Obromios
  • 15,408
  • 15
  • 72
  • 127
  • Are you running your development environment over NFS or some other sort of network share, using Vagrant for example? This seems to be the source of the issue we're having with trying to move to sassc. – boffbowsh Feb 10 '16 at 11:15

2 Answers2

10

This was fixed by removing all the file suffixes in the application.css file. For example

@import 'pages.css.scss'
@import 'morris.css'

to

@import 'pages'
@import 'morris'

This was solved at sassc-rails thanks to boffbowsh and bolandrm

Note that there appears to be other causes of this problem, so another approach is to turn off asset caching.

Obromios
  • 15,408
  • 15
  • 72
  • 127
1

You need to create a config file called importer.rb in lib/sassc/rails/ in your app.

You need to do something like this.

class CSSExtension 
 def postfix 
  ".css" 
 end
 def import_for(original_path, parent_path, full_path)
  import_path = full_path.gsub(/\.css$/,"")
  SassC::Importer::Import.new(import_path)
  end
 end
alexdotsh
  • 166
  • 1
  • 10
  • I tried this, and it did not help. It may be because the definitions are not being autoloaded. I did add ``` config.autoload_paths += Dir["#{config.root}/lib/sassc/rails"] ``` to the application.rb, but these answers http://stackoverflow.com/questions/3356742/best-way-to-load-module-class-from-lib-folder-in-rails-3 indicates that autoloading will only work if the parent directory is same name as the module name. Also that you cannot monkey patch by autoloading and should use a config/initializer. (Siwei Shen's answer). It might help if you could explain what you are trying to do – Obromios Jan 16 '16 at 05:06
  • I have now moved your code to an initializer, with some modifications to may be need to make the context is correct. I checked in the console, and the new definitions are now overloading original methods. However it is still not helping the problem. – Obromios Jan 16 '16 at 05:29