Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tanem/archiver-webpack-plugin
:file_folder: A webpack plugin that generates zip archives.
https://github.com/tanem/archiver-webpack-plugin
archive archiver javascript plugin webpack zip
Last synced: about 4 hours ago
JSON representation
:file_folder: A webpack plugin that generates zip archives.
- Host: GitHub
- URL: https://github.com/tanem/archiver-webpack-plugin
- Owner: tanem
- License: mit
- Created: 2019-06-10T09:29:38.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-04-13T17:42:00.000Z (7 months ago)
- Last Synced: 2024-04-13T18:08:49.296Z (7 months ago)
- Topics: archive, archiver, javascript, plugin, webpack, zip
- Language: TypeScript
- Homepage: https://npm.im/@tanem/archiver-webpack-plugin
- Size: 4.11 MB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Authors: AUTHORS
Awesome Lists containing this project
README
# archiver-webpack-plugin
[![npm version](https://img.shields.io/npm/v/@tanem/archiver-webpack-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@tanem/archiver-webpack-plugin)
[![build status](https://img.shields.io/github/actions/workflow/status/tanem/archiver-webpack-plugin/ci.yml?branch=master&style=flat-square)](https://github.com/tanem/archiver-webpack-plugin/actions?query=workflow%3ACI)
[![coverage status](https://img.shields.io/codecov/c/github/tanem/archiver-webpack-plugin.svg?style=flat-square)](https://codecov.io/gh/tanem/archiver-webpack-plugin)
[![npm downloads](https://img.shields.io/npm/dm/@tanem/archiver-webpack-plugin.svg?style=flat-square)](https://www.npmjs.com/package/@tanem/archiver-webpack-plugin)> A webpack plugin that uses [node-archiver](https://github.com/archiverjs/node-archiver) to generate `.zip`, `.tar`, `.tar.gz`, or `jar` archives when the build is [`done`](https://webpack.js.org/api/compiler-hooks#done).
## Basic Usage
```js
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`, `tar` or `jar`.
- `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](https://www.archiverjs.com/archiver).
- `globOptions` - _Optional_ The [glob options](https://github.com/isaacs/node-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](https://github.com/isaacs/node-glob#glob-primer) that determines what will be included in the archive. Defaults to `'**/*'` which will include all files in the output path.**Example**
```js
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