@tanem/archiver-webpack-plugin
v10.0.1
Published
A webpack plugin that generates zip archives.
Downloads
196
Maintainers
Readme
archiver-webpack-plugin
A webpack plugin that uses node-archiver to generate
.zip
,.tar
,.tar.gz
, orjar
archives when the build isdone
.
Basic Usage
const { ArchiverWebpackPlugin } = require('@tanem/archiver-webpack-plugin')
const path = require('path')
module.exports = {
mode: 'development',
entry: './foo.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'foo.bundle.js',
},
plugins: [new ArchiverWebpackPlugin('zip')],
}
API
Arguments
format
- The archive format. One ofzip
,tar
orjar
.options
- Optional An object containing the optional arguments defined below. Defaults to{}
.destpath
- Optional The destination path within the archive. Defaults to''
, which means files are output to the root of the archive.filename
- Optional The name of the archive.'.zip'
,'.tar'
,'.tar.gz'
or'.jar'
will be appended where appropriate. Defaults to the basename of the webpack output path.formatOptions
- Optional Allows fine-tuning of archiving. Defaults to the archiver defaults.globOptions
- Optional The glob options that will change pattern matching behaviour. Defaults to thenode-glob
defaults, but setscwd
to the output path. AnyglobOptions
passed will take precedence.globPattern
- Optional The glob pattern that determines what will be included in the archive. Defaults to'**/*'
which will include all files in the output path.
Example
const { ArchiverWebpackPlugin } = require('@tanem/archiver-webpack-plugin')
const path = require('path')
module.exports = {
mode: 'development',
entry: './foo.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'foo.bundle.js',
},
plugins: [
new ArchiverWebpackPlugin('tar', {
destpath: 'foo',
filename: 'bar-baz',
formatOptions: { gzip: true },
globOptions: { dot: true, ignore: '*.map' },
globPattern: '*',
}),
],
}
Installation
⚠️ This library requires webpack 4 and Node.js >= 18.
$ npm install @tanem/archiver-webpack-plugin --save-dev
License
MIT