如何加载两个同名的grunt任务?

acm*_*cme 15 gruntjs yeoman

我使用自耕农进行项目.

基本上它工作正常,但在构建过程中我想将我的图像文件夹移动到其他地方.

所以我加载了grunt-contrib-copy让我这样做的任务.但不幸的是,这与yeoman内置的复制任务相冲突.

有没有办法grunt-contrib-copy在我的别名中Gruntfile.js使用它我可以同时使用它们?

grunt.loadNpmTasks('grunt-contrib-copy');

//Here I need to use "copy" again but not referencing the yeoman task but the grunt-contrib-copy task.
grunt.registerTask('build','intro clean coffee compass mkdirs concat css min replace copy time');
Run Code Online (Sandbox Code Playgroud)

Dmi*_*ich 31

grunt.renameTask()可能会帮助你.试试这个:

// temporarily rename yeoman's copy task
grunt.renameTask('copy', 'yeomanCopy');
// load 'copy' from grunt-contrib-copy
grunt.loadNpmTasks('grunt-contrib-copy');
// rename it to something other than 'copy'
grunt.renameTask('copy', 'myCopy');
// rename yeoman's task back to its original name so nothing breaks
grunt.renameTask('yeomanCopy', 'copy');

// now use 'myCopy' for your purposes
// ...
Run Code Online (Sandbox Code Playgroud)