Rails assets do not compile when clicked on production

I am trying to deploy my rails application for production and I am trying to precompile all assets:

My assets.rb file:

Rails.application.config.assets.precompile += %w( *.css.sass ) Rails.application.config.assets.precompile += %w( *.css.scss ) Rails.application.config.assets.precompile += %w( *.css ) Rails.application.config.assets.precompile += %w( *.js ) Rails.application.config.assets.precompile += %w( *.js.coffee ) Rails.application.config.assets.precompile += %w( *.js.coffee.erb ) 

However, when I try to deploy using capistrano, I get the following error:

 DEBUG[c79c6191] rake aborted! DEBUG[c79c6191] Sass::SyntaxError: Undefined variable: "$alert-padding". 

In my assets.rb file, before that, I added each file separately by file, and the deployment worked, however I import some resources into the layout file:

 <%= javascript_include_tag 'application', 'jquery-ui-1.9.2', 'js-example', 'js-example2', 'data-turbolinks-track' => true %> 

But I also import some using asterisks:

 //= require jquery //= require bootstrap-sprockets //= require angular //= require jquery_ujs //= require turbolinks //= require_tree . 

This method worked well when I developed the application, but when I deploy the production application, it seems that the material that I import with asterisks is not imported (i.e. Angular)

Thanks in advance.

EDIT: as requested by my application.css.scss file:

 /* * *= require_tree . *= require_self */ @import "bootstrap-sprockets"; @import "bootstrap"; @import "font-awesome"; 

EDIT2: I also followed this method: bootstrap-sass: Undefined variable: "$ baseLineHeight" , but I need it to precompile all assets.

+5
source share
3 answers

Here is your mistake:

 Sass::SyntaxError: Undefined variable: "$alert-padding". 

The likely reason for this is bootstrap , which you included at the top of the file:

 //= require bootstrap-sprockets 

-

SCSS

I would suggest that the problem is that you are not calling the file using the SCSS preprocessor or that something is wrong with loading the gem that you are calling

If I looked around the net , I would recommend the following:

 #app/assets/stylesheets/application.css.scss @import "bootstrap-sprockets", "bootstrap"; 

-

Precompilation

I will remove all calls from your assets.rb file:

 Rails.application.config.assets.precompile += %w( *.css.sass ) Rails.application.config.assets.precompile += %w( *.css.scss ) Rails.application.config.assets.precompile += %w( *.css ) Rails.application.config.assets.precompile += %w( *.js ) Rails.application.config.assets.precompile += %w( *.js.coffee ) Rails.application.config.assets.precompile += %w( *.js.coffee.erb ) 

All of them are called anyway - you do not need to confirm them in the initializer assets.rb

+2
source

I had the same problem and fixed it by deleting

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

above line from /assets.rb initializers

I hope this helps someone

+1
source

What version of stars do you use? I had a similar problem and I had to use 2.11.0 to get it to work correctly. I think there is some problem using bootstrap and the latest version of asterisks.

0
source

Source: https://habr.com/ru/post/1200683/


All Articles