7

Compass を既存のプロジェクトに追加したいと考えています。次のような現在のプロジェクト構造を維持したい (簡略化):

app/
build/    
 |-compass/
assets/
 |-css/
   |-scss
 |-js/
 |-img/

したがって、すべての SASS ファイルを\assets\css\scssの下に置き、コンパイルした CSS ファイルを\assets\cssに出力したいと考えています。

ランニング:

compass create --bare --sass-dir "assets\css\scss" --css-dir "assets\css"

私のルート直下に Compass config.rb ファイルを作成します。

ただし、ファイルを\build\compassの下に置きたいです。

  1. Compass が config.rb ファイルを作成する場所を制御するにはどうすればよいですか?
  2. Compass のドキュメントによると、config.rb の宣言 (css_dir、sass_dir など) はすべて project_path に対して相対的です。project_path はどこで定義しますか?
4

3 に答える 3

3

Compass は、コマンドを実行したディレクトリと同じディレクトリに config.rb を作成します。プロジェクト パスは、config.rb が存在する場所です。アセットのパスを調整する限り、config.rb は好きな場所に自由に配置できます。

于 2013-09-29T15:46:46.223 に答える
1

これは config.rb の例です:

# Require any additional compass plugins here.
require 'compass/import-once/activate'

# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "../../assets/css"
sass_dir = "../../assets/css/scss"

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

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

# Enable source map
sourcemap = true

そして、このconfig.rb設定では、プロジェクトフォルダーは(あなたが書いたように)次のようになります。

MyFolder
├ app
├ build 
│ └ compass
│   └ config.rb
└ assets
  ├ css/
  │ └ scss/
  ├ js
  └ img

config.rbがない場合は、新しいファイル「config.rb」を作成し、私が書いた構成内にコピー/貼り付けしてください。

ターミナルを開き、MyFolder/build/compass に入力してから、次のようにコンパス コマンドを開始します。compass watch


覚えて

config.rb ファイルと同じフォルダーでコンパス コマンドを実行する必要があります。この場合、MyFolder/build/compass にあります。そうしないと、コンパスが機能しません。

于 2015-09-06T18:49:15.143 に答える