2

1 つの SASS ファイルを保存し、「output_style」と「environment」の設定が異なる 2 つのファイルを出力したいと考えています。

私が実験した2つの方法:

  1. config.rb ファイル内の関数は、同じ SASS ファイルに対して別の拡張子で圧縮アクションを再実行しますが、「output_style」と「environment」を更新します。

  2. 2 つの SASS ファイルをそれぞれ手動で保存します。各ファイルの先頭に、config.rb の「output_style」変数と「environment」変数を更新する何かを追加します。

Grunt でこれを行うことができますが、CodeKit が機能するだけでもいいと思います。

オプション、代替案は?

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 に答える