我想讓我的gruntfile.js自然結構化,這樣微任務就可以一個接一個地跟隨彼此。 假設我有以下結構:註冊不帶grunt.initConfig的Grunt任務
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
clean: {
movedTyping: 'options...'
},
copy: {
typing: 'options...',
lessVariables: 'options...',
html: 'options...'
},
less: {
compile: 'options...'
},
typescript: {
compile: 'options...'
}
});
grunt.registerTask('build', [
// TYPESCRIPT
'typescript:compileSingle',
'copy:typing',
'clean:movedTyping',
// LESS
'less:compile',
'copy:lessVariables',
// HTML
'copy:html'
]);
但我想實現其他結構:
grunt.registerTask('build', function() {
// TYPESCRIPT
grunt.task.run('typescript', 'options...');
grunt.task.run('copy', 'options...');
grunt.task.run('clean', 'options...');
// LESS
grunt.task.run('less', 'options...');
grunt.task.run('copy', 'options...');
// HTML
grunt.task.run('copy', 'options...');
});
如何?
在一個側面note.You會喜歡[一飲而盡(http://gulpjs.com/)更多。 – Vishwanath 2015-04-03 15:56:44