如何使用Compass生成css的单个minify文件?

时间:2016-12-13 04:57:13

标签: sass compass

我想将我的sass文件编译成项目中的单个minify css。

1 个答案:

答案 0 :(得分:0)

使用Sass缩小

在命令行中,输入以下内容:

$ sass --watch style.scss:style.css --style compressed

使用指南针缩小

首先,通过在命令行中输入以下内容,确保已在Compass中设置项目:

$ compass create path/to/your_project

之后,您会注意到Compass已在您的项目目录中创建了两个文件夹; / sass /和/ stylesheets /。它还创建了一个config.rb文件。

打开config.rb文件,您应该会看到类似于以下内容的内容:

# Require any additional compass plugins here.

# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"

# You can select your preferred output style here (can be overridden via the command line):
output_style = :compressed # :expanded or :nested or :compact or :compressed

# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true

# To disable debugging comments that display the original location of your selectors. Uncomment:
line_comments = false


# If you prefer the indented syntax, you might want to regenerate this
# project again passing --syntax sass, or you can uncomment this:
# preferred_syntax = :sass
# and then run:
# sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass

在你的config.rb文件中,第11行可能会被#符号注释掉。取消注释output_style行,使其读取如上例所示。

最后,您需要让Compass开始关注scss文件的更改。在命令行中,输入:

$ cd /path/to/your_project
$ compass watch

结束!

Credits