【发布时间】:2017-03-12 21:02:24
【问题描述】:
我使用 grunt 和 grunt-contrib-copy; 我的目标:我想将文件夹中的所有文件复制到另一个文件夹除了可配置的文件列表
copy: {
files: [{
expand:true,
cwd: './dist/Assets/',
src: [
'**/*',
'!{Css,Images}/**/*',
'!Js/{filetoexlude1.js,filetoexclude2.js}'
],
filter: 'isFile',
dest:'./deploy/Assets/'
}]
}
由于我不想在任务中写入文件列表,因此我编写了一个名为 files.json 的 json 文件,其中包含以下内容:
{
"filestoexcludefromcopy":[
"filetoexclude1.js",
"filetoexclude2.js"
]
}
在 Gruntfile.js 中:
filestoexcludefromcopy: grunt.file.readJSON('files.json').filestoexcludefromcopy,
并修改了我的任务:
copy: {
files: [{
expand:true,
cwd: './dist/Assets/',
src: [
'**/*',
'!{Css,Images}/**/*',
'!Js/{<%= filestoexcludefromcopy%>}'
],
filter: 'isFile',
dest:'./deploy/Assets/'
}]
}
效果很好...除非在 files.json 中只有一个文件...有人可以帮我正确配置任务吗?谢谢!
【问题讨论】:
标签: javascript json gruntjs copy