Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript grunt复制将生成文件夹移动到项目外部_Javascript_Node.js_Gruntjs - Fatal编程技术网

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/***
    表示递归复制所有文件和子文件夹的文件

非常感谢这一点,但在我的构建文件夹中,我现在有了src文件夹,我是否可以只将src的内容放入构建文件夹,而不是实际的src文件夹?我猜pwd设置为src,src设置为*/是