简体   繁体   中英

Including css components of bootstrap-sass gem in rails app

I have in my Gemfile including gem 'bootstrap-sass' and in app/assets/stylesheets/custom.css.scss I have at the top @import "bootstrap";

But this includes all the css of bootstrap bloating the css file download size. Is there a way to include just the css components of bootstrap that I am using?

When you importing "bootstrap" style, acctualy you are importing this file from gem: bootstrap.scss

As you can see It's only importing other files, so you can replace: @import "bootstrap"; with:

// Core variables and mixins
@import "bootstrap/variables"; // Modify this for custom colors, font-sizes, etc
@import "bootstrap/mixins";
// …
// Components: common
@import "bootstrap/sprites";
@import "bootstrap/dropdowns";

Try using minified CSS code. Also when you import your bootstrap file it will import all of it, why do you want just the CSS components when you are have the custom CSS file to work with!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM