[英]uglify with grunt-concurrent not working
I'm trying to use grunt-concurrent to minify my javascript files in parallel. 我正在尝试使用grunt-concurrent来并行缩小我的javascript文件。 I also use usemin and ngmin.
我也使用usemin和ngmin。
When I use uglify without grunt-concurrent I get the expected result with this log output: 当我在没有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.
But when I try to execute this tasks using grunt-concurrent with that configuration: 但是,当我尝试在该配置下使用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'
]
},
I get the message that this tasks are not configured: 我收到此任务未配置的消息:
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.
My build task configuration ist this: 我的构建任务配置如下:
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'
]);
The Question is, how can I make use of grunt-concurrent with uglify and usemin/ngmin? 问题是,我如何在uglify和usemin / ngmin中使用grunt-concurrent?
usemin adds tasks to uglify on the fly but they are for whatever reason not visible in grunt-concurrent. usemin添加了要立即执行任务丑化的任务,但是无论出于何种原因,它们在并发并发时都不可见。 To solve this, you have to manually add the files to uglify:
要解决此问题,您必须手动添加文件以进行uglify:
uglify: {
dist: {
options: {
sourceMap: true
},
files: {
}
},
// you have to add this manually!
"dist/scripts/jquery_and_angular.js": "dist/scripts/jquery_and_angular.js",
"dist/scripts/external-non-angular-libraries.js": "dist/scripts/external-non-angular-libraries.js",
"dist/scripts/modules.js": "dist/scripts/modules.js",
"dist/scripts/scripts.js": "dist/scripts/scripts.js",
"dist/scripts/templates.js": "dist/scripts/templates.js"
},
The problem is, that this is not dry. 问题是,这不是干的。 you have to configure it in the index.html, in grunt-concurrent and here in uglify..
您必须在index.html,grunt-concurrent和uglify中进行配置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.