我正在尝试使用 grunt-concurrent 并行缩小我的 javascript 文件。我也使用 usemin 和 ngmin。
当我在没有 grunt-concurrent 的情况下使用 uglify 时,我会通过以下日志输出得到预期的结果:
Running "uglify:dist" (uglify) task
Running "uglify:dist/scripts/jquery_and_angular.js" (uglify) task
File dist/scripts/jquery_and_angular.js created.
Running "uglify:dist/scripts/external-non-angular-libraries.js" (uglify) task
File dist/scripts/external-non-angular-libraries.js created.
Running "uglify:dist/scripts/modules.js" (uglify) task
File dist/scripts/modules.js created.
Running "uglify:dist/scripts/scripts.js" (uglify) task
File dist/scripts/scripts.js created.
但是当我尝试使用具有该配置的 grunt-concurrent 执行此任务时:
concurrent: {
lessAndMinify: [
'ngmin',
'less'
],
uglify: [
'uglify:dist/scripts/jquery_and_angular.js',
'uglify:dist/scripts/external-non-angular-libraries.js',
'uglify:dist/scripts/modules.js',
'uglify:dist/scripts/scripts.js',
'uglify:dist/scripts/templates.js'
]
},
我收到未配置此任务的消息:
Running "concurrent:uglify" (concurrent) task
Warning: Running "uglify:dist/scripts/jquery_and_angular.js" (uglify) task
Verifying property uglify.dist/scripts/jquery_and_angular\.js exists in config...ERROR
>> Unable to process task.
Warning: Required config property "uglify.dist/scripts/jquery_and_angular\.js" missing. Use --force to continue.
Aborted due to warnings. Used --force, continuing.
Running "uglify:dist/scripts/jquery_and_angular.js" (uglify) task
Verifying property uglify.dist/scripts/jquery_and_angular\.js exists in config...ERROR
>> Unable to process task.
Warning: Required config property "uglify.dist/scripts/jquery_and_angular\.js" missing. Use --force to continue.
Aborted due to warnings.
Warning: Running "uglify:dist/scripts/modules.js" (uglify) task
Verifying property uglify.dist/scripts/modules\.js exists in config...ERROR
>> Unable to process task.
Warning: Required config property "uglify.dist/scripts/modules\.js" missing. Use --force to continue.
Aborted due to warnings. Used --force, continuing.
Running "uglify:dist/scripts/modules.js" (uglify) task
Verifying property uglify.dist/scripts/modules\.js exists in config...ERROR
>> Unable to process task.
Warning: Required config property "uglify.dist/scripts/modules\.js" missing. Use --force to continue.
我的构建任务配置是这样的:
grunt.registerTask('build', [
'clean:dist',
'ngtemplates',
'copy:indexHtml',
'replace',
'useminPrepare',
'concat',
'copy:dist',
'copy:generated',
'concurrent:lessAndMinify', // ngmin and less
// 'concurrent:uglify',
'uglify',
'rev',
'usemin'
]);
问题是,如何将 grunt-concurrent 与 uglify 和 usemin/ngmin 结合使用?