2

I want to save one SASS file and output two files with different settings, "output_style" and "environment".

Two methods I've experimented with:

  1. Function in the config.rb file to rerun the compress action on the same SASS file with a different extension, but updates the "output_style" and "environment".

  2. Manually save each of the two SASS files, with something in the top of each file that updates the "output_style" and "environment" variables in the config.rb.

I can do this in Grunt, but I'm thinking it'd be nice to just have CodeKit work.

Options, alternatives?

4

1 回答 1

0

第 1 步:开发配置config.rb应如下所示:

# Basic configuration.
http_path = "/"
css_dir = "css"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "js"

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

# Enable debugging comments that display the original location of your selectors.
line_comments = true

# Re-compile the sass files using the minified configuration.
on_stylesheet_saved do
  `compass compile -c config_minified.rb --force`
end

第 2 步:您必须添加另一个配置文件config_minified.rb,它应该如下所示:

# Basic configuration.
http_path = "/"
css_dir = "css/minified"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "js"

# Compressed the output for production.
output_style = :compressed

# Disable debugging comments for production.
line_comments = false

第 3 步:像往常一样编译,您就可以开始了:

compass watch

/css/minified/style.css自动生成。
按照这些步骤操作后,项目应如下所示:

/css
/css/style.css
/css/minified/style.css
/images
/sass
/sass/style.scss
config.rb
config_minified.rb

编辑

如果您不想弄乱每个项目的相对路径,您可以更改config_minified.rb以使用相对于根文件夹的 css 文件夹。

# do not use the css_dir = "css/minified" because it will break the images.
css_dir = "css-minified"
于 2016-01-26T13:44:58.977 回答