javascript Grunt 复制单个文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17244113/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Grunt copy a single file
提问by bsr
What is the format to specify a single file copy for grunt copy task
为 grunt 复制任务指定单个文件副本的格式是什么
copy:{
dist:{
files:[
{
expand:true,
cwd:'<%= yeoman.app %>',
dest:'<%= yeoman.dist %>/scripts/jq.min.js',
src: ['components/jq/dist/jq.min.js']
}
]
if my yeoman.app
dir is A
and yeoman.dist
is B
, this copies the file to
如果我的 yeoman.app
目录是A
并且yeoman.dist
是B
,这会将文件复制到
/b/scripts/jq.min.js/components/jq/dist/jq.min.js
what I want is copy it as /b/scripts/jq.min.js
我想要的是将其复制为 /b/scripts/jq.min.js
how can I do this.
我怎样才能做到这一点。
EDIT: I see an issue which implements the support. https://github.com/gruntjs/grunt-contrib-copy/issues/3
编辑:我看到一个实现支持的问题。 https://github.com/gruntjs/grunt-contrib-copy/issues/3
回答by Brian Lewis
Does this work?
这行得通吗?
copy: {
dev: {
files: [{
cwd: '<%= yeoman.app %>/components/jq/dist/',
src: 'jq.min.js',
dest: '<%= yeoman.dist %>/scripts/',
expand: true
}]
}
}
回答by Ryan M
Copy multiple source file locations to a single destination folder use flatten.
使用 flatten 将多个源文件位置复制到单个目标文件夹。
copy: {
dev: {
files: [{
cwd: '<%= yeoman.app %>',
src: ['/components/jq/dist/jq.min.js','/components/jq/dist/jq2.min.js', '/components/bs/dist/bs.js'],
dest: '<%= yeoman.dist %>/scripts/',
expand: true,
flatten: true
}]
}
}