我如何加载两个同名的咕噜声任务? [英] How can I load two grunt tasks with the same name?
本文介绍了我如何加载两个同名的咕噜声任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上它工作正常,但在构建过程中,我想将我的图像文件夹移动到其他位置。
因此,我加载了 grunt-contrib-copy
任务,它可以让我这么做。但不幸的是,这与yeoman内置拷贝任务相冲突。
有什么方法可以将 grunt-contrib-copy
在我的 Gruntfile.js
中,所以我可以使用它们两个?
grunt.loadNpmTasks( '咕噜-的contrib拷贝');
//这里我需要再次使用copy,但不要引用yeoman任务,而是引用grunt-contrib-copy任务。
grunt.registerTask('build','intro clean coffee compass mkdirs concat css min min replace copy time');
解决方案
grunt.renameTask()可能会帮助你。试试这个:
$ b
//暂时重命名yeoman的复制任务
grunt.renameTask('复制','yeomanCopy');
//从grunt-contrib-copy载入'copy'
grunt.loadNpmTasks('grunt-contrib-copy');
//将其重命名为'copy'以外的内容
grunt.renameTask('copy','myCopy');
//将yeoman的任务重命名为其原始名称,因此没有任何内容会打破
grunt.renameTask('yeomanCopy','copy');
//现在为你的目的使用'myCopy'
// ...
Im using yeoman for a project.
Basically it's working fine, but during the build process I want to move my images folder to somewhere else.
So I loaded the grunt-contrib-copy
task which would let me do that. But unfortunately this conflicts with the yeoman built-in copy task.
Is there any way to alias the grunt-contrib-copy
in my Gruntfile.js
so I can use both of them?
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');
解决方案
grunt.renameTask() will probably help you here. Try this:
// 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
// ...
这篇关于我如何加载两个同名的咕噜声任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文