简体   繁体   English

在Rails应用程序中包含Bootstrap-Sass gem的CSS组件

[英]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"; 我在包含gem'bootstrap gem 'bootstrap-sass' Gemfile中,以及在app/assets/stylesheets/custom.css.scss中,位于顶部的@import "bootstrap";

But this includes all the css of bootstrap bloating the css file download size. 但这包括引导的所有css膨胀css文件的下载大小。 Is there a way to include just the css components of bootstrap that I am using? 有没有办法只包含我正在使用的引导程序的css组件?

When you importing "bootstrap" style, acctualy you are importing this file from gem: bootstrap.scss 导入“ bootstrap”样式时,实际上是从gem导入此文件: bootstrap.scss

As you can see It's only importing other files, so you can replace: @import "bootstrap"; 如您所见,它仅导入其他文件,因此可以替换: @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. 尝试使用缩小的CSS代码。 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! 同样,当您导入引导文件时,它也会全部导入,为什么要使用自定义CSS文件时只想要CSS组件!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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