現時点では、yeoman ビルド プロセスをカスタマイズすることはできません。ただし、この回避策を使用できます。次のコードを独自の 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'
ただし、このコードはyeoman のソースからコピーされたものであり、更新された場合は自分で同じことを行う必要があることに注意してください。