سؤال

I want to copy the content of /pckg to /dist with grunt.js. Here is the structure:

  |-- folder1
  |     |
  |     |-- folder2
  |           |
  |           |-- pckg
  |                 |
  |                 |--myfolder
  |                 |    |
  |                 |    |-- myfiles
  |                 |
  |                 |--myfiles
  |
  |
  |-- dist
        |
        |--myfolder
        |   |
        |   |-- myfiles
        |
        |--myfiles

Here's my 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']);
};

When I run Grunt, it keep the path. It copy everything in dit/folder1/folder2/pckg. What is wrong ?

Thanks for your help !

هل كانت مفيدة؟

المحلول

Here's what I've used:

copy: {
  main: {
    expand: true,
    cwd: 'folder1/folder2/pckg/',
    src: ['**'],
    dest: 'dist/'
  }
}

نصائح أخرى

use flatten:true

copy: {
    main: {
        files: [ 
            {expand: true, src: ['components/xxx/*'], dest: 'dist/', flatten: true}
        ]
    }
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top