【发布时间】:2015-09-16 18:28:52
【问题描述】:
我的印象是,在 grunt.registerTask(taskName, taskList) 中,taskList 将按顺序运行(即,一个完成,然后再进入下一个)。估计不是这样吧?
鉴于此任务:
grunt.registerTask('local-debug', [
'clean',
'concat:local',
'ngconstant:common',
'targethtml:local',
'copy:debug'
]);
如何在运行复制之前确保 concat/ngconstant/targethtml 完整?我遇到了问题,因为 ngconstant 在 concat 完成之前正在运行。
编辑:任务未按顺序运行的详细信息。
'concat:local' 创建一个被 'ngconstant:common' 使用的 aggregate.json 文件。如果我删除现有的 aggregate.json 文件,则 ngconstant:common 任务会出错,因为 aggregate.json 文件丢失(但文件确实在 ngconstant 运行后创建)。另外,如果我不删除该文件,而只是进行更改,例如更改 concat 使用的源文件中的版本号,则 ngconstant 创建的文件不会接受更改,因为它不会等到新的聚合。 json由concat创建。
编辑2:任务代码
concat: {
options: {
banner: '{"appConfig": {',
footer: "}}",
separator: ','
},
local: {
src: ["app/config/common-config.json", "app/config/local.json"],
dest: "app/config/aggregate-config.json"
}
},
ngconstant: {
options: {
space: ' ',
wrap: '(function(){\n\n"use strict";\n\n {%= __ngModule %}\n\n}());',
name: 'CoreConfig',
dest: 'app/scripts/config.js'
},
common: {
constants: grunt.file.readJSON('app/config/aggregate-config.json')
}
}
【问题讨论】:
-
Grunt 按顺序运行任务列表,因此您的问题可能出在其他地方。是什么症状让您认为没有?
-
好吧,我就是这么想的,所以我会三重检查所有任务。我确实在问题中添加了详细信息。
-
从您的详细信息看来,您正在观看您的文件,并且在观看期间出现问题,而不是直接致电
local-debug。然后请发布您的watch任务的完整配置。 -
我在手动调用
local-debug任务时发生了这种情况,但在任何正在运行的手表之外。 -
嗯。你能发布你的 concat:local 配置吗?
标签: gruntjs grunt-contrib-concat grunt-contrib-copy