Rails Precompilation: Why is the LESS.ERB file not working?

I am trying to use the Rails Asset Pipeline to work with a less.erb file.

Before using LESS, I used SCSS. With SCSS, I could have the SCSS.ERB files. Everything worked perfectly.

Unfortunately, the UI Framework that I want to use (Semantic-UI) does not support SCSS, only LESS.

So I changed:

Added these gems:

gem 'less-rails', '~> 2.7.0' gem 'therubyracer', '~> 0.12.2' gem 'less-rails-semantic_ui', '~> 2.0.7' 

Then I add the _colors.less.erb file to the pipeline of my resource (in assets / stylesheets / core / _colors.less.erb), with this content:

 @import "variables/_colors.less"; <% colors_list = %w(primary secondary gray green red blue yellow purple orange brown violet pink olive teal) %> /*-------------------- Background Colors ---------------------*/ <% colors_list.each do |color| %> .bg-color-<%=color%> { background-color: @color-<%=color%>; } .bg-color-<%=color%>-darker { background-color: @color-<%=color%>-darker; } .bg-color-<%=color%>-dark { background-color: @color-<%=color%>-dark; } .bg-color-<%=color%>-light { background-color: @color-<%=color%>-light; } .bg-color-<%=color%>-lighter { background-color: @color-<%=color%>-lighter; } <% end %> .bg-color-black { background-color: @color-black; } .bg-color-white { background-color: @color-white; } .bg-color-gray-darkest { background-color: @color-gray-darkest; } .bg-color-gray-lightest { background-color: @color-gray-lightest; } 

The problem is that unlike scss.erb files, these less.erb files are not precompiled from erb to less.

It returns an error: "core / _colors.less" not found

Does anyone know why this is happening?

+4
source share
1 answer

I'm not sure, but you say that "_colors.less" is in "assets / stylesheets / core / _colors.less.erb" and you are importing from "variables / _colors.less"

I think your import should be "core / _colors.less"

0
source

All Articles