我在我的 angularJS 项目中使用 grunt 和 grunt-angular-gettext。
我想让 gruntnggettext_extract
在源文件更新时运行 grunt 任务,并且nggettext_compile
每当更新“po”文件时。
我想我可以通过这种方式将任务名称添加到我的“grunt.task.run”任务列表中:
...
grunt.registerTask('serve', 'Compile then start a connect web server', function (target) {
grunt.task.run([
'nggettext_extract', <== added task, just executed on the first run
'nggettext_compile', <== added task, just executed on the first run
'clean:server',
'wiredep',
'concurrent:server',
'autoprefixer',
'connect:livereload',
'watch'
]);
});
...
但不幸的是,这仅适用于第一次 grunt 运行,而不适用于之后......即使我的项目中的任何文件发生更改,我也可以同时运行这两个任务(我不确定如何在 Gruntfile.js 中指定依赖项,我对它很陌生... :-()。
如果有任何帮助,这些是我的 nggettext_ 任务配置(非常标准):
...
nggettext_extract: {
pot: {
files: {
'po/template.pot': [ 'app/**/*.html', 'app/scripts/**/*.js' ]
}
}
},
nggettext_compile: {
all: {
files: {
'app/scripts/translations.js': ['po/*.po']
}
}
},
...