创建覆盖“options”但使用任务级别“src”的子任务
Create subtasks that override `options` but use task level `src`
到目前为止我的 g运行t 文件
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.
据我所知这是不可能的。您需要为每个目标显式定义一个 src。
您可以在配置之外声明一个变量并将其添加到每个目标:
var mySources = ['file1.txt', 'file2.txt']; //declared outside config
development: {
src: mySources, //add variable to each target
或者您可以在配置中声明一个变量:
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 目标并覆盖选项。
到目前为止我的 g运行t 文件
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.
据我所知这是不可能的。您需要为每个目标显式定义一个 src。
您可以在配置之外声明一个变量并将其添加到每个目标:
var mySources = ['file1.txt', 'file2.txt']; //declared outside config
development: {
src: mySources, //add variable to each target
或者您可以在配置中声明一个变量:
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 目标并覆盖选项。