I have the following directory structure, and I want to zip the content of dev folder and place it in the root of the generated archive without it being wrapped inside a top level folder:
_build/ #build scripts
dist/ #destination
dev/ #source
Here is the code (gruntfile.js inside _build):
compress: {
main : {
options : {
archive : "../dist/dev.zip"
},
files : [
{ expand: true, src : "../dev/**/*" }
]
}
}
I wish I could zip only the contents of dev folder and place it into dist folder. But when I try to do so I, all the content of dev are zipped inside a root folder.
Actual generated zip:
dist/
|____ dev.zip
|_____ dev/
|_____ index.html
|_____ styles/style.css
But I want the zip file to be like this:
dist/
|____ dev.zip
|_____ index.html
|_____ styles/style.css
You see? the files are being wrapped in a folder(with the same name as the zip) instead of being place into the root of zip file.
Can this be achieved in some way?
Thank you
you can do as exposed here : https://github.com/gruntjs/grunt-contrib-compress/issues/33
For example :
compress : {
main : {
options : {
archive : "myapp.zip"
},
files : [
{ expand: true, src : "**/*", cwd : "dist/" }
]
}
}
will generate myapp.zip in the root path, countaining all files and directory included in /dist, but not the dist directory itself.
another example, more in line with original question:
compress: {
main: {
options: {
archive : "../dist/dev.zip"
},
files: [
{
expand: true,
cwd: '../dev/',
src: ['**'],
}
]
},
},
This should give your flat structure:
dist/
|____ dev.zip
|_____ index.html
|_____ styles/style.css
checkout this great article on grunt-compress: http://www.charlestonsw.com/what-i-learned-about-grunt-compress/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With