diff --git a/index.js b/index.js index 108329f..940a8c5 100644 --- a/index.js +++ b/index.js @@ -9,15 +9,26 @@ WebpackArchivePlugin.prototype.apply = function(compiler) { compiler.plugin("after-emit", function(compiler, callback) { let output = compiler.options.output.path; - // Create tarfile - let tar = archiver('tar'); + // Create archivers + let zip = archiver('zip'); + zip.pipe(fs.createWriteStream(`${output}.zip`)); + let tar = archiver('tar', { + gzip: true, + gzipOptions: { + level: 1 + } + }); tar.pipe(fs.createWriteStream(`${output}.tar.gz`)); + // for(let asset in compiler.assets) { - console.log(asset); - tar.append(fs.createReadStream(file1), {name: 'file1.txt'}); + if(compiler.assets.hasOwnProperty(asset)) { + zip.append(fs.createReadStream(compiler.assets[asset].existsAt), {name: asset}); + tar.append(fs.createReadStream(compiler.assets[asset].existsAt), {name: asset}); + } } + zip.finalize(); tar.finalize(); callback();