首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >罗盘中的imagesDir & imagesPath是什么?

罗盘中的imagesDir & imagesPath是什么?
EN

Stack Overflow用户
提问于 2013-09-03 04:59:59
回答 2查看 2.7K关注 0票数 4

我使用的是grunt-contrib-compass,在设置中,有imagesDirimagesPath这样的选项。我只是想知道这是干什么的,我该怎么用呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-11-25 03:34:54

很明显,与compass URL Helpers一起使用的选项。如果在imagesDir中指定了Gruntfile.js,则可以调用compass函数images-url()来生成图像文件夹的路径。

例如,您是这样指定Gruntfile.js

代码语言:javascript
复制
compass: {
  build: {
    options: {
      cssDir: './source/css/',
      sassDir: './source/css/',
      imagesDir: './source/images/',
      force: true,
      outputStyle: 'expanded',
    }
  }
}

下面是从scss文件调用函数的方式:

代码语言:javascript
复制
background-image: image-url( 'test.png' );

当您运行该任务时,它将被编译为:

代码语言:javascript
复制
background-image: url('/./source/images/test.png');

同样的事情也适用于fontsDir,您只需要调用不同的compass函数font-url()。如果您想找到更多的详细信息,请按http://compass-style.org/reference/compass/helpers/urls/链接

票数 6
EN

Stack Overflow用户

发布于 2013-09-03 11:58:36

我不确定它能比文档有多少更清晰

代码语言:javascript
复制
[imagesDir](https://github.com/gruntjs/grunt-contrib-compass#imagesdir)
Type: String
The directory where you keep your images.

代码语言:javascript
复制
[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.

也许罗盘构型基准的定义也会有帮助?

代码语言:javascript
复制
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中的任何其他选项一样指定这些选项:

代码语言:javascript
复制
compass: {
  staging: {
    options: {
      imagesDir: 'images'
    }
  }
}

注意:当您使用罗盘图像url助手时,这些通常用于编译正确的图像路径。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/18584382

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档