如何使用grunt.js复制没有完整路径的文件? [英] How to copy files without the full path with grunt.js?
问题描述
我想用grunt.js将 / pckg
的内容复制到 / dist
。
这里是结构:
| - folder1
| |
| | - folder2
| |
| | - pckg
| |
| | --myfolder
| | |
| | | - myfiles
| |
| | --myfiles
|
|
| - dist
|
| --myfolder
| |
| | - myfiles
|
| --myfiles
这是我的 当我运行Grunt时,它保留了路径。它将所有内容复制到 感谢您的帮助! I want to copy the content of Here's my When I run Grunt, it keep the path. It copy everything in Thanks for your help ! Here's what I've used:
这篇关于如何使用grunt.js复制没有完整路径的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! Gruntfile.js < code
$ $ p $ module.exports =函数(grunt){
//程序包配置
grunt.initConfig({
//元数据
pkg:grunt.file.readJSON('package.json'),
//复制文件
副本:{
main:{
展开:true,
src:'folder1 / folder2 / pckg / **',
dest:'dest /'
}
}
});
//载入提供复制任务的插件。
grunt.loadNpmTasks('grunt-contrib-copy');
//默认任务。
grunt.registerTask('default',['copy']);
};
dit / folder1 / folder2 / pckg
中。
有什么不对?
复制:{
main:{
expand: true,
cwd:'folder1 / folder2 / pckg /',
src:['**'],
dest:'dist /'
}
}
/pckg
to /dist
with grunt.js.
Here is the structure: |-- folder1
| |
| |-- folder2
| |
| |-- pckg
| |
| |--myfolder
| | |
| | |-- myfiles
| |
| |--myfiles
|
|
|-- dist
|
|--myfolder
| |
| |-- myfiles
|
|--myfiles
Gruntfile.js
module.exports = function (grunt) {
// Package configuration
grunt.initConfig({
// Metadata
pkg: grunt.file.readJSON('package.json'),
//Copy files
copy: {
main: {
expand: true,
src: 'folder1/folder2/pckg/**',
dest: 'dest/'
}
}
});
// Load the plugin that provides the "copy" task.
grunt.loadNpmTasks('grunt-contrib-copy');
// Default task(s).
grunt.registerTask('default', ['copy']);
};
dit/folder1/folder2/pckg
.
What is wrong ?copy: {
main: {
expand: true,
cwd: 'folder1/folder2/pckg/',
src: ['**'],
dest: 'dist/'
}
}