我的Gruntfile.js包含一个用于Compass的任务:
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
// FILE PATHS (custom)
dir: {
css: 'resources/styles/css',
fonts: 'resources/fonts',
html: 'resources/html',
images: 'resources/images',
includes: 'resources/includes',
node_modules: 'node_modules',
prototypes: 'resources/html/prototypes',
resources: 'resources',
scripts: 'resources/scripts',
scss: 'resources/styles/scss',
styles: 'resources/styles',
styleguide: 'resources/styleguide',
vendor: 'resources/vendor',
user: {
htdocs: '/Volumes/VR\ Mini\ Backup/Backups/Web/Active/myproject/htdocs'
}
},
// COMPASS
compass: {
dist: {
options: {
...
importPath: [
'<%= dir.user.htdocs %>/<%= dir.resources %>/vendor',
'<%= dir.user.htdocs %>/<%= dir.resources %>/fonts'
]指南针选项之一是importPath。这需要一个绝对/系统路径。importPath的一个例子是/system/path/to/htdocs/resources/vendor。
由于几个开发人员将在我的项目上工作,所以我想使/system/path/to/htdocs成为动态的。
有任何方法可以从这个文件中访问Gruntfile.js的路径吗?
谢谢。
发布于 2013-09-19 23:44:07
你可以利用节点路径模块。
在您的gruntfile顶部,添加var path = require('path');。
path.resolve()会给你绝对的路径。
https://stackoverflow.com/questions/18904729
复制相似问题