4

を使用していますが、設定にはやgrunt-contrib-compassなどのオプションがあります。それは何のためにあるのだろうか、そしてどうやって使うのだろうか?imagesDirimagesPath

4

2 に答える 2

6

そのため、どうやらそのオプションは と組み合わせて使用​​ する必要がありますcompass URL Helpers。で指定imagesDirした場合は、関数をGruntfile.js呼び出して画像フォルダーへのパスを生成できます。compassimages-url()

たとえば、次のように指定しますGruntfile.js

compass: {
  build: {
    options: {
      cssDir: './source/css/',
      sassDir: './source/css/',
      imagesDir: './source/images/',
      force: true,
      outputStyle: 'expanded',
    }
  }
}

scssこれは、ファイルから関数を呼び出す方法です。

background-image: image-url( 'test.png' );

タスクを実行すると、次のようにコンパイルされます。

background-image: url('/./source/images/test.png');

にも同じことが当てはまります。別の関数fontsDirを呼び出すだけです。詳細については、http://compass-style.org/reference/compass/helpers/urls/のリンクをたどってください。compassfont-url()

于 2013-11-25T03:34:54.330 に答える
0

ドキュメントにあるものよりもどれだけ明確になるかわかりません

[imagesDir](https://github.com/gruntjs/grunt-contrib-compass#imagesdir)
Type: String
The directory where you keep your images.

[imagesPath](https://github.com/gruntjs/grunt-contrib-compass#imagespath)
Type: String
Default: images
The directory where the images are kept. It is relative to the projectPath.

コンパスの構成リファレンスからの定義も役立つでしょうか?

images_dir: The directory where the images are kept. It is relative to the project_path. Defaults to "images".

images_path: The full path to where images are kept. Defaults to <project_path>/<images_dir>.

これらは、Gruntfile.js の他のオプションと同じように指定できます。

compass: {
  staging: {
    options: {
      imagesDir: 'images'
    }
  }
}

注: これらは通常、コンパスimage-url ヘルパーを使用したときに、画像への正しいパスをコンパイルするために使用されます。

于 2013-09-03T11:58:36.763 に答える