Skip to content

Commit

Permalink
Archive both types
Browse files Browse the repository at this point in the history
  • Loading branch information
astralarya committed Aug 5, 2016
1 parent a2046d2 commit 9eab2ac
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9eab2ac

Please sign in to comment.