0

我想连接我src/目录中的几个 js 文件,例如每个页面上需要的文件以及需要多个文件的某些特定页面。我想用当前目录结构完整复制的其余文件。这些是仅在一个页面上使用的文件,并且是该页面唯一的页面特定 jsfile。

所以我想排除第一类任务的srcand属性,排除最后一个任务中的那些。files

如何做到这一点?

4

1 回答 1

0

You could use create an array with all the files you mean to concatenate outside task scope. Then you loop through that array to concatenate the javascript files listed in the array in one task like uglify and create another task to copy all the files through another task like copy.

But the magic would happen when you use the same pre-defined array to list the exceptions that are not going to be included in the copy task.

OR you could prefixes like:

uglify: {
    dist: {
        files: {
            'dest/output.min.js': [
                'app/js/**/concatenate-*.js',
            ]
        }
    }
}

copy: {
    dist: {
        src : [
            'app/js/**/*.js',
            // exclude files
            '!app/js/**/concatenate-*.js'
        ]
    }
}

Note that I only added the relevant part within each task, normally the tasks would need more configuration than just that.

于 2014-02-26T19:30:44.377 回答