【发布时间】:2013-11-26 12:44:17
【问题描述】:
考虑关注Gruntfile.js
module.exports = function(grunt) {
var
stylusFiles = [
{
expand: true,
cwd: 'radio/static/css/',
src: ['*.styl'],
ext: ['.css']
},
{
expand: true,
cwd: 'radio/static/polymer/radio-light/',
src: ['**/*.styl'],
ext: ['.css']
},
{
expand: true,
cwd: 'radio/static/themes/',
src: ['**/*.styl'],
ext: ['.css']
}
];
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
stylus: {
all: {
files: stylusFiles,
},
},
watch: {
files: [
'radio/static/css/*.styl',
'radio/static/themes/**/*.styl',
'radio/static/polymer/radio-light/**/*.styl',
],
tasks: ['stylus:all'],
}
});
// Other stuff
};
Stylus 任务编译在指定文件夹中找到的每个 .styl 文件。
观看任务现在导致重新编译所有 .styl 文件,我只想重新编译观看过的文件。
我已经阅读了一些关于 watch.event 的内容,但我不明白如何使用监视的路径名运行默认任务(例如 stylus:single)。
换句话说,有没有办法实现手写笔子任务,可以由grunt.task.run()使用自定义文件选项运行?
已更新:解决方案在我自己的答案中。
【问题讨论】: