Javascript grunt复制将生成文件夹移动到项目外部
你好,我有一个文件结构,看起来像这样Javascript grunt复制将生成文件夹移动到项目外部,javascript,node.js,gruntjs,Javascript,Node.js,Gruntjs,你好,我有一个文件结构,看起来像这样 |-App |------|src |----------|js |----------|img |----------|css |----------|less |----------|tpl |----------|index.php |- Gruntfile.js (withing parent app folder) |- package.json (withing parent app folder) 我想做的是将src文件夹的所有内容移动到一个
|-App
|------|src
|----------|js
|----------|img
|----------|css
|----------|less
|----------|tpl
|----------|index.php
|- Gruntfile.js (withing parent app folder)
|- package.json (withing parent app folder)
我想做的是将src文件夹的所有内容移动到一个build文件夹中,build文件夹被创建,但在App文件夹之外,我真的不明白为什么,第二,当它复制src文件夹时,它复制的是实际的src文件夹,我想复制它的所有子文件夹,而不是父src文件夹,第三,副本忽略index.php文件,为什么?下面是我当前的Gruntfile.js
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
copy: {
build: {
cwd: '.',
src: ['src/*/*'],
dest: '../build',
expand: true
}
},
clean: {
build: {
cwd: '.',
src: ['build']
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.registerTask('move', 'Moves the project to the build folder', ['copy', 'clean']);
};
你走错了路。将
build
选项更改为:
build: {
cwd: '.',
src: ['src/**/*'],
dest: './build',
expand: true
}
表示生成目录是在父目录中创建的(。/build
是父目录)。
表示递归复制所有文件和子文件夹的文件src/***