Search code examples
ruby-on-railsrubysprocketsrails-assetssass-rails

How to disable sprockets from compiling stylesheets directory


I'm currently trying to move away from the obsolete sassc and sassc-rails gems and migrate to a recommended alternative - dartsass-rails. While doing this, I had to update my sprockets gem which now requires a manifest.js config file. According to what I read, the manifest.js file should contain directives of assets to be rendered. I added the following to my manifest.js;

//= link_tree ../images
//= link_tree ../javascript .js

As seen from above, I wish to make sprockets compile only image and javascript assets. On running bundle exec rails assets:precompile, I get the following error;

LoadError: cannot load such file -- sassc (LoadError)

From what I've know so far, sprockets would only try to compile scss/sass files only when it's among the linked files in the manifest.js file. I didn't add the stylesheets directory so I'm not sure why this error occurs. I have also tried deleting the .scss files I have in my stylesheets directory but the error still persists.

How can I get rid of the error as well as disable sprockets from compiling assets in stylesheets directory please?


Solution

  • Thanks to @Alex comment, the solution was to make sure there wasn't any reference to any scss file via the Rails.application.config.assets.precompile list.

    In my case, there were additions to the list from external libraries. Compilation completed successfully after taking care of those scss file additions which was causing sprockets to look for a sassc library.