bodyfarmer
bodyfarmer

Reputation: 402

How to link scss file with style sheet link tag in Ruby on Rails

<%= stylesheet_link_tag 'main', media: 'all', 'data-turbolinks-track' =>true  %>

Ruby on Rails seems to assume it's a main.css and throw an error.

How do I link this correctly to main.scss?

Upvotes: 2

Views: 9161

Answers (1)

Drenmi
Drenmi

Reputation: 8787

Only application.css.scss is precompiled by default. All files that are required through this file are also compiled. Normally, you would request your other files from within this file using either *= require_tree and *= require_self or @import.

If you still want to explicitly include the main.css.scss using stylesheet_link_tag like in your question, you need to add it to your list of precompiled assets in config/initializers/assets/ like so:

Rails.application.config.assets.precompile += %w( main.css )

Upvotes: 10

Related Questions