在另一个文件中的grunt中创建任务(Create task in grunt in another file)

编程入门 行业动态 更新时间:2024-10-15 20:25:42
在另一个文件中的grunt中创建任务(Create task in grunt in another file)

我在Grunt写了一个简单的任务。 现在,我想将此任务导出到另一个文件,我遇到了问题。 如何找到我的任务文件? 此任务只是从网站搜索字符串并将其放入文件中。 我正在尝试加载它: grunt.loadTasks('grunt-find'); 我在里面有find.js的文件(grunt-find)。 但它不起作用......我可以在其他地方添加find.js吗?

提前致谢。

I wrote simple task in Grunt. Now, I would like to export this task to another file, and I have a problem with it. How can I find file with my task? This task just searches string from website and putting it in the file. I'm trying load it by: grunt.loadTasks('grunt-find'); I have file (grunt-find) with find.js inside. But it doesn’t work... Can I have to add find.js somewhere else?

Thanks in advance.

最满意答案

grunt.loadTask()将加载作为参数提供的目录中的每个JS文件; 所以,基本上,你必须做类似的事情:

grunt.loadTasks("tasks");

你可能有一个名为“tasks”的目录:

project root |- tasks |--- file.js |- Gruntfile.js

grunt.loadTask() will load every JS file in the directory provided as argument; so, basically, you have to do something like:

grunt.loadTasks("tasks");

and you may have a directory called "tasks":

project root |- tasks |--- file.js |- Gruntfile.js

更多推荐

本文发布于:2023-08-04 16:43:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1418745.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   grunt   Create   task   file

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!