我的 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'
]
compass 之一 options是
importPath
.这需要一个绝对/系统路径。一个例子 importPath
是 /system/path/to/htdocs/resources/vendor
.由于几个开发人员将在我的项目上工作,我想制作
/system/path/to/htdocs
动态的。有什么办法可以访问到
Gruntfile.js
的路径吗?从这个文件中?谢谢。
最佳答案
您可以利用 Node's path module .
在 gruntfile 的顶部,添加 var path = require('path');
.path.resolve()
会给你绝对路径。
关于compass-sass - 如何在 Gruntfile 中访问 Gruntfile 的绝对路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18904729/