Reputation: 11796
I get an error when Heroku is trying to compile assets of my Rails app:
remote: -----> Preparing app for Rails asset pipeline
remote: Running: rake assets:precompile
remote: rake aborted!
remote: Sass::SyntaxError: Undefined variable: "$btn-default-border".
remote: (in /tmp/build_8402012299c8c367a1dc15dd7f5cd85f/app/assets/stylesheets/auctions.css.scss:42)
remote: /tmp/build_8402012299c8c367a1dc15dd7f5cd85f/app/assets/stylesheets/auctions.css.scss:42
When I run rake assets:precompile
locally it works.
Here my application.css.scss
/*
*
*= require bootstrap-datepicker3
*/
@import "variables";
@import "bootstrap-sprockets";
@import "bootstrap";
@import "auctions";
auctions.css.scss
.form-control-feedback {
pointer-events: all;
&:hover {
cursor:pointer;
border: 1px solid $btn-default-border;
background: $gray-lighter;
border-radius: 5px;
}
}
Why is it working locally but not on Heroku? Is Heroku trying to compile auctions.css.scss
without other dependencies?
Upvotes: 0
Views: 1222
Reputation: 1633
Try bumping Rails.application.config.assets.version
in config/initializers/assets.rb
.
I had the same exact issue deploying to Heroku right after I switched Sprockets require
to @import
lines in my application manifest file. (I had issues with CSS rule precedences and realized I was doing something wrong. This article directed me to better conventions: https://content.pivotal.io/blog/structure-your-sass-files-with-import)
I fixed it by bumping the Rails.application.config.assets.version
in my config/initializers/assets.rb
.
Bumping the version prompted my app to reprocess all asset files, which seemed to reset its understanding of certain files and their dependence on variables.
Upvotes: 2
Reputation: 21
go to the file config/initializers/assests.rb
add line or update.
Rails.application.config.assets.precompile += [/.*\.js/,/.*\.scss/]
and run
bundle exec assets:precompile
Upvotes: 0
Reputation: 2703
Make sure that production.rb have the following code or else add it
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w( *.css *.js )
Upvotes: 0