zip-webpack-plugin
Webpack plugin to zip up emitted files.
Compresses all assets into a zip file.
Installation
For Webpack 4 / 5:
npm install --save-dev zip-webpack-plugin
For Webpack 3:
npm install --save-dev zip-webpack-plugin@2.0.0
Usage
webpack.config.js
var ZipPlugin = require('zip-webpack-plugin');
module.exports = {
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
plugins: [
new ZipPlugin({
path: 'zip',
filename: 'my_app.zip',
extension: 'ext',
pathPrefix: 'relative/path',
pathMapper: function(assetPath) {
if (assetPath.endsWith('.png'))
return path.join(path.dirname(assetPath), 'images', path.basename(assetPath));
return assetPath;
},
include: [/\.js$/],
exclude: [/\.png$/, /\.html$/],
fileOptions: {
mtime: new Date(),
mode: 0o100664,
compress: true,
forceZip64Format: false,
},
zipOptions: {
forceZip64Format: false,
},
})
]
};