目前,它是不可能定製自耕農構建過程。但是,您可以使用此解決方案。將以下代碼複製到自己的Gruntfile:
// Clobber the original targets
var targets = {
// Add as many custom targets as you want, using custom modules, etc.
// Keep the existing targets
default : ' rjs concat css min img rev usemin manifest',
usemin : 'usemin-handler rjs concat css img rev usemin manifest',
text : 'usemin-handler rjs concat css min rev usemin manifest',
buildkit : 'usemin-handler rjs concat css min img rev usemin manifest html:buildkit',
basics : 'usemin-handler rjs concat css min img rev usemin manifest html:basics',
minify : 'usemin-handler rjs concat css min img rev usemin manifest html:compress',
test : 'usemin-handler rjs concat css img rev usemin manifest',
yourbuild : 'intro clean mkdirs rjs'
};
// If we clobber targets, we have to rebuild targetList, the below is copy paster from Yeoman.js
var targetList = grunt.log.wordlist(Object.keys(targets));
// We also have to rebuild the build task with the new targetList
grunt.registerTask('build', 'Run a predefined target - build:<target> \n' + targetList, function(target) {
var valid = Object.keys(targets);
target = target || 'usemin';
if (valid.indexOf(target) === -1) {
grunt.log
.error('Not a valid target')
.error(grunt.helper('invalid targets', targets));
return false;
}
var tasks = ['intro', 'clean coffee compass mkdirs', targets[target], 'copy time'].join(' ');
// Now overwrite the task for our costume build
if(target === 'yourbuild') {
tasks = targets[target];
}
// Conditionally remove compass/manifest task if either compass or
// phantomjs binary is missing. Done only for `test` target (specifically
// used for our `npm test`). For each, output warning infos.
if(target === 'test') {
tasks = grunt.helper('build:skip', tasks, 'compass');
tasks = grunt.helper('build:skip', tasks, 'phantomjs', 'manifest');
}
grunt.log.subhead('Running ' + target + ' target')
.writeln(' - ' + grunt.log.wordlist(tasks.split(' '), { separator: ' ' }));
grunt.task.run(tasks);
});
現在你可以更改以下行來定製自己的編譯過程:
yourbuild : 'intro clean mkdirs rjs'
但請記住,此代碼是從自耕農複製來源,如果它更新,你必須自己做。
是的,這是更有意義的,謝謝Sindre – climboid