Skip to content

Commit

Permalink
feat: Added the archive option, allowing custom Archiver instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
Seldszar committed Mar 15, 2018
1 parent 7771ea5 commit c1fa8b1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Arguments:
* `test`: All assets matching this RegExp are processed. Defaults to every asset.
* `format`: The archive format. Defaults to `"zip"`.
* `formatOptions`: The archive format options. Defaults to `"{}"`.
* `archive`: An Archiver instance. Defaults to the built-in instance.


[npm]: https://img.shields.io/npm/v/archiver-webpack-plugin.svg
Expand Down
3 changes: 2 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class ArchiverWebpackPlugin {
this.test = options.test;
this.format = options.format || "zip";
this.formatOptions = options.formatOptions || {};
this.archive = options.archive;
}

apply(compiler) {
Expand All @@ -16,7 +17,7 @@ class ArchiverWebpackPlugin {

compiler.plugin("emit", (compilation, callback) => {
const { assets } = compilation;
const archive = archiver(this.format, this.formatOptions);
const archive = this.archive || archiver(this.format, this.formatOptions);

Object.keys(assets).forEach(file => {
if (Array.isArray(this.test)) {
Expand Down

0 comments on commit c1fa8b1

Please sign in to comment.