Grunt.js 복사를 사용하여 디렉토리의 모든 파일을 다른 디렉토리로 복사하십시오.
빌드 프로세스의 일부로 디렉터리의 모든 파일을 다른 디렉터리로 복사하려고합니다. 내가 명시 적으로 지정한 개별 파일에 대해 잘 작동하지만 전체 디렉토리를 복사하려고 할 때 전체 디렉토리 구조를 복사하거나 전혀 복사하지 않는 것과 같은 이상한 작업을 수행합니다. 내 GruntFile.js의 관련 부분은 다음과 같습니다.
copy: {
myvoice: {
files: [
{ src:"src/html/index.html", dest:"dist/myvoice/index.html" },
{ src:"src/html/css/style.css", dest:"dist/myvoice/css/style.css" },
{ src:"src/html/js/require.js", dest:"dist/myvoice/js/require.js" },
{ src:"build/myvoice/main.js", dest:"dist/myvoice/js/main.js" },
{ src:"src/html/css/fonts/*", dest:"dist/myvoice/css/fonts/" }
]
}
},
특히 내가 작업 할 수없는 마지막 줄입니다.
{ src:"src/html/css/fonts/*", dest:"dist/myvoice/css/fonts/" }
이 답변 의 flatten: true
옵션은 경우에 따라 작동 할 수 있지만 더 일반적인 요구 사항 (제 경우와 같이)은 폴더와 하위 폴더 구조를있는 그대로 . 대부분의 경우 하위 폴더가 있으면 코드에서 그런 방식으로 참조되는 것 같습니다. 이 작업의 핵심 은 지정된 작업 디렉토리에 상대적인 폴더 구조를 유지 하는 옵션입니다.dest
cwd
copy: {
files: {
cwd: 'path/to/files', // set working folder / root to copy
src: '**/*', // copy all files and subfolders
dest: 'dist/files', // destination folder
expand: true // required when using cwd
}
}
이 작업은 파일 glob을 지정하는 경우 폴더 구조를 유지합니다. 원하는 것은 flatten
구조를 제거하는 옵션입니다.
{
expand: true,
flatten: true,
src: ['src/html/css/fonts/**'],
dest: 'dist/myvoice/css/fonts/',
filter: 'isFile'
}
Github repo 에서 사용 가능한 나머지 옵션을 찾으십시오 . 도움이 되었기를 바랍니다.
나는의 형식 변화하는 것을 추가하고 싶습니다 글로브을 에 SRC하는 복사의 작동 방식을 수정합니다.
가리키는 OUT으로 bmoeskau 위, 다음이 복사됩니다 모든 것을 내부 dist/
와로 이동 path/to/dir
(이미 존재하는 경우 대상을 덮어 쓰기).
copy: {
files: {
expand: true,
dest: 'path/to/dir',
cwd: 'dist/',
src: '**'
}
}
그러나 다음 사항에 유의하십시오.
copy: {
files: {
expand: true,
dest: 'path/to/dir',
cwd: 'dist/',
src: '*'
}
}
dist/
디렉토리뿐만 아니라 내부의 파일 만 복사 하지만 해당 디렉토리의 내용을 대상으로 복사 하지는 않습니다 .
또한 다음 src: '*/*'
은 .NET 내부의 내용이있는 디렉토리 만 복사 dist/
합니다. 즉, 내부 파일은 dist/
복사되지 않습니다.
copy: {
files: {
expand: true,
dest: 'path/to/dir',
cwd: 'dist/',
src: '*/*'
}
}
Finally, same as above, but src: '**/**'
will copy only files inside dist/
as well as files inside dist/
subdirectories to path/to/dir
. So there will be no folders inside the destination.
copy: {
files: {
expand: true,
dest: 'path/to/dir',
cwd: 'dist/',
src: '*/*',
flatten: true,
filter: 'isFile'
}
}
Had to use egdy instead curly braces for the files segment (in Coffeescript)...
copy: {
files: [
cwd: 'path/to/files'
src: '**/*'
dest: 'dist/files'
expand: true
]
}
If you are developing with angular yeoman , then this is the better way to copy with grunt. expand: true is required when using cwd. <%= yeoman.app %> is just the app route ('.').
{
expand: true,
cwd: '<%= yeoman.app %>/data',
dest: '<%= yeoman.dist %>/data',
src: ['**']
}
'IT박스' 카테고리의 다른 글
알파벳 순서로 File.listFiles하는 방법? (0) | 2020.09.09 |
---|---|
a : before에서 밑줄 만 제거하는 방법은 무엇입니까? (0) | 2020.09.09 |
CSS : 오른쪽 하단에 요소를 배치하는 방법은 무엇입니까? (0) | 2020.09.09 |
Objective-C의 읽기 전용 속성? (0) | 2020.09.09 |
행 내부의 TextField로 인해 레이아웃 예외 발생 : 크기를 계산할 수 없음 (0) | 2020.09.09 |