Gruntjs 创建覆盖'options'但使用任务级别'src'的子任务`

Gruntjs 创建覆盖'options'但使用任务级别'src'的子任务`,gruntjs,grunt-contrib-uglify,Gruntjs,Grunt Contrib Uglify,到目前为止,我的Gruntile uglify: { src: [ ... ], dest: 'js/application.min.js', options: { 'compress': {}, 'reserveDOMCache': true, 'enclose': undefined, 'exportAll': false, 'expression': false,

到目前为止,我的Gruntile

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
时,它将响应
未创建任何文件。

据我所知,这是不可能的。您需要为每个目标明确定义一个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
mysourcesinder:['file1.txt'],//在配置中声明
发展:{
src:“”,//每个目标中的引用变量

或者,您可以使用类似于
grunt override config
的方法,只声明一个丑陋的目标和选项的覆盖。

我能够调整您的解决方案,使其以我想要的方式与
src:'