archiver-webpack-plugin

npm version build status coverage status npm downloads

A webpack plugin that uses node-archiver to generate .zip, .tar, or .tar.gz archives when the build is done.

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 of zip or tar.
  • 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' or '.tar.gz' 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 the node-glob defaults, but sets cwd to the output path. Any globOptions 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 Node.js 10 or greater.

$ npm install @tanem/archiver-webpack-plugin --save-dev

License

MIT

Last updated

v5.0.18

Install

npm install @tanem/archiver-webpack-plugin
yarn add @tanem/archiver-webpack-plugin

BUNDLE SIZE

Not Available

DOWNLOAD TIME

Not Available

CDNs

extras

Contributors

  • tanem