-->

我怎么能装载两个咕噜任务具有相同的名称?(How can I load two grunt task

2019-07-05 06:53发布

即时通讯使用的自耕农的一个项目。

基本上,它的正常工作,但在构建过程中,我想我的图片文件夹移动到别的地方。

所以我装了grunt-contrib-copy任务,这将让我做。 但不幸的是这种冲突与自耕农内置的复制任务。

有没有什么办法,以别名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');

Answer 1:

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
// ...


文章来源: How can I load two grunt tasks with the same name?