我有不同的JS文件集,我想连接和uglify。一个是应用程序,一个是网站。我的gruntfile.js看起来像下面的那个。问题是只有website
运行,即使我已将grunt任务注册为:grunt.registerTask('default', ['concat:app', 'concat:website', 'uglify']);
concat: {
app: {
js: {
src: [
'app/js/vendor/jquery.js',
'app/js/app/ui.js',
'app/js/app/data.js'
],
dest: 'app/js/app.js'
},
css: {
src: [
'app/css/vendor/normalize.css',
'app/css/vendor/ui.css',
'app/css/vendor/style.css',
],
dest: 'app/css/app.css'
}
},
website: {
src: [
'app/js/vendor/jquery.js',
'app/js/website/scripts.js'
],
dest: 'app/js/common.js'
}
},
uglify: {
development: {
options: {
preserveComments: false
},
files: {
'app/js/app.min.js': 'app/js/app.js',
'app/js/common.min.js': 'app/js/common.js'
}
}
}
答案 0 :(得分:1)
concat可以在同一个目标中连接多个文件和类型,但是你必须使用正确的grunt语法(https://www.npmjs.com/package/grunt-contrib-concat#multiple-files-per-target):
concat: {
app: {
'app/js/app.js': [
'app/js/vendor/jquery.js',
'app/js/app/ui.js',
'app/js/app/data.js'
],
'app/css/app.css': [
'app/css/vendor/normalize.css',
'app/css/vendor/ui.css',
'app/css/vendor/style.css',
],
}
},