[英]Using a grunt plugin's Gruntfile task rather than one from the executing Gruntfile
我有一个grunt插件,我们称它为grunt-my-plugin
,在该插件的Gruntfile中,我有一个需要运行的特定cssmin
任务。 测试grunt插件时,一切正常,但是,当我将其安装在另一个项目上时,出现以下错误:
Warning: Task "cssmin" not found. Use --force to continue.
起初,我只是打电话给grunt.task.run('cssmin');
从插件的任务文件中获取,但是在看到错误之后,我意识到使用此插件的Gruntfile需要指向相应的任务配置,因此我添加了:
grunt.task.loadTasks('./Gruntfile.js');
那仍然是我的错误,所以我尝试了:
grunt.task.loadTasks('./node_modules/grunt-my-plugin/Gruntfile.js');
仍然出现错误。 那么,我该如何解决呢? 该插件不需要使用它的Gruntfile中的特定配置。 cssmin
任务用于创建tmp副本并对其运行度量。 关于如何实现这一目标的任何想法? 谢谢!
确保以下各项:
package.json
中将grunt-contrib-cssmin
插件列为依赖项 npm install
-ed(请与npm ls grunt-contrib-cssmin
) grunt.task.run('cssmin')
之前,使用grunt.config()
为cssmin
任务提供配置(请参阅此GitHub评论以了解想法)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.