到目前为止我的grunt文件
uglify: {
src: [
...
],
dest: 'js/application.min.js',
options: {
'compress': {},
'reserveDOMCache': true,
'enclose': undefined,
'exportAll': false,
'expression': false,
'preserveComments': false,
'report': 'min',
'sourceMap': false,
'sourceMapIn': undefined,
'sourceMapIncludeSources': false,
'sourceMapName': undefined,
'wrap': undefined
},
development: {
options: {
'beautify': false,
'mangle': true
}
},
production: {
options: {
'beautify': true,
'mangle': false
}
}
}
但是,当我运行任务uglify:development
时,它将以No files created.
答案 0 :(得分:1)
据我所知,这是不可能的。您需要为每个目标明确定义src。
您可以在配置之外声明一个变量并将其添加到每个目标:
var mySources = ['file1.txt', 'file2.txt']; //declared outside config
development: {
src: mySources, //add variable to each target
或者你可以在config中声明一个变量:
mySourcesInside: ['file1.txt'], //declared within config
development: {
src: '<%= mySourcesInside%>', //reference variable in each target
或者您可以使用类似grunt-override-config
https://github.com/masakura/grunt-override-config的内容,并声明一个uglify目标并覆盖选项。