I am trying to deploy my rails app to production and I'm trying to precompile all of the 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, I had added each asset individually file by file, and the deploy was working, however, I am importing some assets in the layout file:
<%= javascript_include_tag 'application', 'jquery-ui-1.9.2', 'js-example', 'js-example2', 'data-turbolinks-track' => true %>
But I am also importing some using sprockets:
//= require jquery
//= require bootstrap-sprockets
//= require angular
//= require jquery_ujs
//= require turbolinks
//= require_tree .
This method was working well while I was developing the app, but when I deploy the app to production, it seems like stuff that I am importing using sprockets is not being imported (i.e. Angular)
Thanks in advance.
EDIT: As requested, 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 of the assets.
Here's your error:
Sass::SyntaxError: Undefined variable: "$alert-padding".
The likely cause of this is bootstrap
that you've included in the top of the file:
//= require bootstrap-sprockets
--
SCSS
I would suggest the problem is either that you're not calling the file with the SCSS preprocessor, or that there's something wrong with the bootstrap gem you're calling
Having looked around online, I would recommend the following:
#app/assets/stylesheets/application.css.scss
@import "bootstrap-sprockets", "bootstrap";
--
Precompile
I would remove all the 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 these are called anyway - you don't need to reaffirm them in the assets.rb
initializer
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With