我正在使用grunt-contrib-compress压缩我的部署包。我有以下配置:
// Zip up the distribution folder and give it a build name. The folder can then be uploaded to the Chrome Web Store.
grunt.registerTask('compress-extension', 'compress the files which are ready to be uploaded to the Chrome Web Store into a .zip', function () {
// There's no need to cleanup any old version because this will overwrite if it exists.
grunt.config.set('compress', {
dist: {
options: {
archive: 'Streamus v' + grunt.option('version') + '.zip'
},
files: [{
src: ['dist/**'],
dest: '',
}]
}
});
grunt.task.run('compress');
});
这导致了一个额外的目录结构级别,我想避免。压缩后,结构如下:
'Streamus v0.xxx.zip' -> 'dist' -> '[sub directories]'
我希望只是:
'Streamus v0.xxx.zip' -> '[sub directories]'
最简单的方法是做什么?我可以在compress的“files”配置部分表达这种愿望吗?也许有一个扁平?
答案 0 :(得分:0)
哦,我明白了。如果您将“cwd”设置为要排除的文件夹,然后将“src”设置为考虑新的cwd,则可以按预期运行:
// Zip up the distribution folder and give it a build name. The folder can then be uploaded to the Chrome Web Store.
grunt.registerTask('compress-extension', 'compress the files which are ready to be uploaded to the Chrome Web Store into a .zip', function () {
// There's no need to cleanup any old version because this will overwrite if it exists.
grunt.config.set('compress', {
dist: {
options: {
archive: 'Streamus v' + grunt.option('version') + '.zip'
},
files: [{
src: ['**'],
dest: '',
cwd: 'dist/',
expand: true
}]
}
});
grunt.task.run('compress');
});