Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grunt Compress without root folder

I'm trying to compress a directory using grunt. I have tried the following sections in my grunt file.

compress: {
    main: {
       options: {
           archive: 'dist/output.zip',
           mode: 'zip'
       },
       files: [{
           src: ['build/*'],
           cwd: 'build',
           expand: true
       }]
    }
}

which gives me an empty zip file. Or

    compress: {
        main: {
            options: {
                archive: 'dist/output.zip',
                mode: 'zip'
            },
            files: [{
                src: ['build/*']
            }]
        }
    }

which gives me the following structure in my zip file

output.zip
 - build
   - my files

but I would like to remove the build directory to get

output.zip
 - my files

What changes can I make to get this structure?

like image 984
Jim Jeffries Avatar asked Feb 21 '26 13:02

Jim Jeffries


1 Answers

Have you tried:

compress: {
    main: {
       options: {
           archive: 'dist/output.zip',
           mode: 'zip'
       },
       files: [{
           src: ['**/*'],
           cwd: 'build/',
           expand: true
       }]
    }
}
like image 90
Rhys Avatar answered Feb 24 '26 06:02

Rhys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!