gpt4 book ai didi

javascript - Grunt 自定义目标

转载 作者:行者123 更新时间:2023-12-03 08:07:32 27 4
gpt4 key购买 nike

假设我有 3 种 grunt 目标模式:quickbuilddist

我还有一个自定义目标make-stuff:

grunt.registerTask('make-stuff', [
'someCSStask',
'someUtility',
'somePackage',
'isolatedTask' // More on this below
]);

...在上述所有 3 种目标模式下运行(快速、构建、分布),如下所示:

grunt.registerTask('quick', [
'some-task1',
'make-stuff'
]);

grunt.registerTask('build', [
'some-task1',
'some-task2',
'make-stuff'
]);

grunt.registerTask('dist', [
'some-task3',
'build' // make-stuff gets ran here since we reference 'build'
]);

我想在每个目标模式下正常运行make-stuff,除了quick,我希望它忽略isolatedTask

最佳答案

如果这是您的设置,为什么不将“isolatedTask”移至构建中?

grunt.registerTask('build', [
'some-task1',
'some-task2',
'make-stuff',
'isolatedTask'
]);

否则,尝试这样的事情

grunt.registerTask(
'isolatedTask',
'Isolated tasks for make-stuff, skip if target mode is quick.',
function() {
var target = this.args[0];
if (target === 'quick') { return; }

// logic here
}
);

grunt.registerTask(
'quick',
function() {
grunt.run.tasks([
...,
'isolatedTask:' + this.nameArgs
]);
}
);

关于javascript - Grunt 自定义目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34316496/

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