如何在一个命令中 运行 两个不同的 G运行t 任务?
How to run two different Grunt task in one command?
我正在分别使用 'cssmin' 和 'sass' g运行t 任务,当我可以在我的任何东西文件。
cssmin: {
target: {
files: [{
cwd: srcCss,
src: ['**/*.css', '*.css'],
dest: buildCss
}]
}
},
sass: {
target: {
files: [{
cwd: srcScss,
src: ['**/*.scss', '*.scss'],
dest: srcCss
}]
}
}
这很容易做到:你需要使用 watch 插件,
- npm 安装 g运行t-contrib-watch
- grunt.loadNpmTasks('grunt-contrib-watch');
3.
grunt.initConfig({
watch: {
scripts: {
files: ['lib/*.js'],
tasks: ['jshint'],
options: {
spawn: false,
},
},
},
jshint: {
all: {
src: ['lib/*.js'],
},
},
});
// 默认任务。
grunt.registerTask('default', 'watch');
- 现在只需 运行 g运行t in cmd.
我正在分别使用 'cssmin' 和 'sass' g运行t 任务,当我可以在我的任何东西文件。
cssmin: {
target: {
files: [{
cwd: srcCss,
src: ['**/*.css', '*.css'],
dest: buildCss
}]
}
},
sass: {
target: {
files: [{
cwd: srcScss,
src: ['**/*.scss', '*.scss'],
dest: srcCss
}]
}
}
这很容易做到:你需要使用 watch 插件,
- npm 安装 g运行t-contrib-watch
- grunt.loadNpmTasks('grunt-contrib-watch');
3.
grunt.initConfig({
watch: {
scripts: {
files: ['lib/*.js'],
tasks: ['jshint'],
options: {
spawn: false,
},
},
},
jshint: {
all: {
src: ['lib/*.js'],
},
},
});
// 默认任务。
grunt.registerTask('default', 'watch');
- 现在只需 运行 g运行t in cmd.