简体   繁体   English

Bootstrap-sass gem:如何有选择地选择所需的CSS组件?

[英]Bootstrap-sass gem: How to selectively just take the CSS components that you need?

We're using this gem to integrate Bootstrap in our Rails app. 我们正在使用此gem将Bootstrap集成到我们的Rails应用程序中。 I've been looking to cut some css components that we don't need, an example of which is the Glyphicons. 我一直在寻找削减一些我们不需要的css组件,例如Glyphicons。 I'm just having some trouble understanding this piece of code in the README: 我在理解README中的这段代码时遇到了一些麻烦:

You can also import components explicitly. 您也可以显式导入组件。 To start with a full list of modules copy this file from the gem: 要从模块的完整列表开始,请从gem复制此文件:

# copy and prepend "bootstrap/" to the @import paths:
sed 's/@import "/@import "bootstrap\//' \
 $(bundle show bootstrap-sass)/vendor/assets/stylesheets/bootstrap/bootstrap.scss > \
 app/assets/stylesheets/bootstrap-custom.scss

What exactly should I do here? 我到底该怎么办?

The line you refer to is a command you need to run in your command line (which needs to be unix based so use mac, linux or unix). 您所指的行是您需要在命令行中运行的命令(该命令必须基于UNIX,因此请使用Mac,Linux或UNIX)。 What it does is access a file ( bootstrap.scss ), and extract specific lines from it. 它的作用是访问文件( bootstrap.scss ),并从中提取特定行。 Then, instead of displaying the result on the screen, it writes it to a file ( bootstrap-custom.scss ), which, after the command runs, will contain a list of all the modules bootstrap uses. 然后,它没有将结果显示在屏幕上,而是将其写入文件( bootstrap-custom.scss ),该文件在命令运行后将包含bootstrap使用的所有模块的列表。 You can now delete those you do not want to use. 现在,您可以删除不想使用的那些。

More info: 更多信息:

sed 's/@import "/@import "bootstrap\\//' - this line uses sed, a unix utility that parses and transforms text, to find only the correct lines. sed 's/@import "/@import "bootstrap\\//' -此行使用sed(一种unix实用程序,它可以解析和转换文本)仅找到正确的行。

$(bundle show bootstrap-sass) - the $() indicates that the result of the command inside should be pasted into this place in the longer command outside them. $(bundle show bootstrap-sass) -$()指示内部命令的结果应该粘贴到外部命令中的此位置中。

\\ - Appears at the end of the 1st & 2nd lines. \\ -出现在第一行和第二行的末尾。 It means that although I press enter II am still typing my command, so don't run it yet. 这意味着尽管我按Enter II仍在键入命令,所以请不要运行它。

`>' - redirects the output from the screen to a file. `>'-将输出从屏幕重定向到文件。

Hope this helps. 希望这可以帮助。

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

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