gpt4 book ai didi

javascript - load-grunt-config 未找到目标任务

转载 作者:行者123 更新时间:2023-12-03 07:33:36 24 4
gpt4 key购买 nike

我想将一个大的 grunt 文件分割成更小的部分,并得出了这些文章: https://github.com/firstandthird/load-grunt-config http://ericnish.io/blog/how-to-neatly-separate-grunt-files/然而,我似乎遗漏了一些明显的东西。当我发出“grunt testtask”时,找不到任务。显然,我做了一些非常错误的事情,但我不明白。以下是文件的内容,已尽可能精简:

gruntfile.js:
module.exports = function(grunt) {
var path = require('path');

require('load-grunt-config')(grunt, {
configPath: path.join(process.cwd(), 'grunt3'),
init: true
});
};

grunt3/testtask.js:
module.exports = {
copy: {
main:
{
files:
[{
src: "test1.txt",
dest: "test2.txt"
}]
}
}
};

I added an aliases file:
module.exports = {
'default': [],
'mytesttask': [
'testtask'
]
};

找到默认值。对于 mytesttalk,我得到“未找到测试任务”。aliases.js 不应该为文件名(testtask)或“复制”执行 registerTask (我也尝试使用“复制”作为目标任务)吗?根据 --config-debug 有一个名为“testtask”的配置对象。我在这里缺少什么?

谢谢。

附录:发现这篇关于同一主题的非常简单且直接的文章,它展示了如何进一步简化。只是,再一次,它不起作用。未找到别名中指定的任务。例如'mytesttask': [ 'testtask'] -> testtask 未找到,尽管有一个 grunt/testtask.js 文件包含原始 gruntfile 中的任务。我错过了什么?

最佳答案

在这篇优秀文章的帮助下http://mattbailey.io/a-beginners-guide-to-grunt-redux.html该模块的一位作者在 github 上发表评论,我终于发现了我的想法中的缺陷。这些文件不是按任务或目标组织的,而是按 grunt 模块组织的。因此,您必须将它们命名为copy.js(来自grunt-contrib-copy)、cssmin.js(来自grunt-contrib-cssmin)、concat.js(来自grunt-contrib-concat)并放置各种目标在这些文件中。不是相反(正如我所想的)。也许文档中的其他人很清楚这一点,但对我来说却不清楚。马特·贝利 (Matt Bailey) 的那篇文章真的很棒,因为它只展示了真正必要的内容。我上面引用的 Eric Nishio 的文章过于复杂,因为它没有考虑别名文件。

关于javascript - load-grunt-config 未找到目标任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35712402/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com