user938363
user938363

Reputation: 10358

Broken bootstrap in production on Rails 4/ubuntu

We fixed broken bootstrap on production server (ubuntu) before. But this time the problem is sticky.

Here is our config/environment/production.rb

config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? #false

  config.assets.js_compressor = :uglifier

  config.assets.compile = true 

  config.assets.digest = true

Here is a list of files in assets/stylesheet:

enter image description here

Here is assets/javascripts:

enter image description here

The Rails 4 production deployment used to work fine before this deployment. This time however after deployment, we did as usual:

  RAILS_ENV=production bundle exec rake assets:precompile

But bootstrap is broken. The CSS is completely off on home page and bootstrap carousal does not work any more.

In config/environment/production.rb, we added:

config.assets.precompile =  ['*.js', '*.scss', '*.css', '*.css.erb']

But this change renders page completely no show with error ($main-bk-color not defined. The var is defined in user_menus.css.scss as #FFF). What else we can try to fix the broken bootstrap?

Upvotes: 1

Views: 44

Answers (1)

Ken Stipek
Ken Stipek

Reputation: 1522

You are going to want to import your css files in application.css.scss and not depend on the precompile. Example:

# app/assets/stylesheets/applicaiton.css.scss
@import "./bootstrap-theme.css.scss";
@import "./user_menus.css.scss"
...

That way your files have access to the SASS variables everywhere and not just in the file they are being created.

Upvotes: 1

Related Questions