Grunt.js: copy file without its parent directory

Evan Emolo

I am using the following in a Grunfile.js to copy index.html in the exports directory:

grunt.initConfig({
  copy: {
    main: {
      files: [
        {expand: true, src: ['./views/index.html'], dest: 'exports/'},
      ]
    }
  }
});

grunt.loadNpmTasks('grunt-contrib-copy');

grunt.registerTask('default', [ 'copy' ]);

What I would like to achieve is placing the file directly in the exports root without the views directory. So the path would be /exports/index.html.

Is this possible?

matth

Use the flatten attribute for the file config:

{expand: true, src: ['./views/index.html'], dest: 'exports/', flatten:true},

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Create file and its parent directory

From Dev

Grunt: Watch file changes and compile parent directory

From Dev

Grunt.js manipulate parent directory

From Java

Copy all files from directory to another with Grunt.js copy

From Dev

How to find a file and copy its directory?

From Dev

Move each file into its parent directory in linux

From Dev

How to copy files without the full path with grunt.js?

From Dev

How to copy files without the full path with grunt.js?

From Dev

Copy file on SFTP to another directory without roundtrip

From Dev

Zip a file without including the parent directory

From Dev

How to copy a file within its original directory, most easily?

From Dev

Can a file be edited with the 'write' permission on it but not on its parent directory?

From Dev

How to copy multiple files with a same name from children directory to another directory without losing the parent directory?

From Dev

VB.NET Retrieve File path of File in Parent directory without parent Directory path included

From Dev

Copy map file on grunt with sass

From Dev

Grunt-Contrib-Copy, how to copy contents of a directory keeping the same folder structure without overwriting existing files/folders in dest folder?

From Dev

Using Grunt.js to copy all HTML files from one directory structure to another

From Dev

Grunt copy task can not retain directory structure

From Dev

Copy files to directory outside project with Grunt

From Dev

puppet copy directory but not its content

From Dev

Recursively copy file to a directory all its sub-directory in command prompt

From Dev

Copy history of subdirectory to parent directory

From Dev

Pythonic way to extract the file name and its parent directory from the full file path?

From Dev

Copy file to directory

From Dev

Copy a file into a created directory

From Dev

File not copy to correct directory

From Dev

Copy file to current directory?

From Dev

RewriteRule for a file in a parent directory

From Dev

Move File in parent directory

Related Related

  1. 1

    Create file and its parent directory

  2. 2

    Grunt: Watch file changes and compile parent directory

  3. 3

    Grunt.js manipulate parent directory

  4. 4

    Copy all files from directory to another with Grunt.js copy

  5. 5

    How to find a file and copy its directory?

  6. 6

    Move each file into its parent directory in linux

  7. 7

    How to copy files without the full path with grunt.js?

  8. 8

    How to copy files without the full path with grunt.js?

  9. 9

    Copy file on SFTP to another directory without roundtrip

  10. 10

    Zip a file without including the parent directory

  11. 11

    How to copy a file within its original directory, most easily?

  12. 12

    Can a file be edited with the 'write' permission on it but not on its parent directory?

  13. 13

    How to copy multiple files with a same name from children directory to another directory without losing the parent directory?

  14. 14

    VB.NET Retrieve File path of File in Parent directory without parent Directory path included

  15. 15

    Copy map file on grunt with sass

  16. 16

    Grunt-Contrib-Copy, how to copy contents of a directory keeping the same folder structure without overwriting existing files/folders in dest folder?

  17. 17

    Using Grunt.js to copy all HTML files from one directory structure to another

  18. 18

    Grunt copy task can not retain directory structure

  19. 19

    Copy files to directory outside project with Grunt

  20. 20

    puppet copy directory but not its content

  21. 21

    Recursively copy file to a directory all its sub-directory in command prompt

  22. 22

    Copy history of subdirectory to parent directory

  23. 23

    Pythonic way to extract the file name and its parent directory from the full file path?

  24. 24

    Copy file to directory

  25. 25

    Copy a file into a created directory

  26. 26

    File not copy to correct directory

  27. 27

    Copy file to current directory?

  28. 28

    RewriteRule for a file in a parent directory

  29. 29

    Move File in parent directory

HotTag

Archive