虽然试图做一些通用的咕噜任务,我卡住了访问变量/选项。grunt中是否有全局变量?
我需要某种全局变量或类似的东西。 看来我忽略了一些东西。
如果我运行grunt sassCompile:myprojectFolder
,一切工作正常 而grunt sassWatch:myprojectFolder
没有。
我在详细模式下运行它,它似乎项目路径是空的,而指南针被监视。
罗盘选项(从详细输出):
sassCompile:config="projectRoot/myprojectFolder/config.rb" ...
sassWatch:config="config.rb" ...
这在Gruntfile.js被用于测试:
什么我做错了?
(function() {
'use strict';
module.exports = function (grunt) {
grunt.initConfig({
compass: {
dev: {
options: {
config: "<%= projectPath %>config.rb",
basePath: "<%= projectPath %>",
specify: ["<%= projectPath %>src/sass/style*.scss","!**/*ie*.scss"],
bundleExec: true
}
}
},
watch: {
css: {
files: ['<%= projectPath %>../**/*.scss'],
tasks: ['compass']
}
}
});
grunt.registerTask('sassCompile', 'compass', function (project) {
grunt.config('projectPath', 'projectRoot/' + project + '/');
grunt.task.run('compass');
});
grunt.registerTask('sassWatch', 'watch', function (project) {
grunt.config('projectPath', 'projectRoot/' + project + '/');
grunt.task.run('watch');
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-compass');
};
}());
感谢您提供有关流程的提示。 我现在将全部运行为假。 (这个任务会比最后的样本大得多) – evilru