https://github.com/feflow/offline-webpack-plugin
离线包打包插件
https://github.com/feflow/offline-webpack-plugin
Last synced: about 1 month ago
JSON representation
离线包打包插件
- Host: GitHub
- URL: https://github.com/feflow/offline-webpack-plugin
- Owner: feflow
- License: mit
- Created: 2018-03-19T14:05:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-10-10T12:54:46.000Z (over 7 years ago)
- Last Synced: 2025-06-30T18:03:28.200Z (12 months ago)
- Language: JavaScript
- Homepage:
- Size: 521 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# zip-webpack-plugin [](https://travis-ci.org/erikdesjardins/zip-webpack-plugin)
Webpack plugin to zip up emitted files.
Compresses all assets into a zip file.
## Installation
`npm install --save-dev zip-webpack-plugin`
## Usage
**webpack.config.js**
```js
var ZipPlugin = require('zip-webpack-plugin');
module.exports = {
// ...
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
plugins: [
new ZipPlugin({
// OPTIONAL: defaults to the Webpack output path (above)
// can be relative (to Webpack output path) or absolute
path: 'zip',
// OPTIONAL: defaults to the Webpack output filename (above) or,
// if not present, the basename of the path
filename: 'my_app.zip',
// OPTIONAL: defaults to 'zip'
// the file extension to use instead of 'zip'
extension: 'ext',
// OPTIONAL: defaults to the empty string
// the prefix for the files included in the zip file
pathPrefix: 'relative/path',
// OPTIONAL: defaults to the identity function
// a function mapping asset paths to new paths
pathMapper: function(assetPath) {
// put all pngs in an `images` subdir
if (assetPath.endsWith('.png'))
return path.join(path.dirname(assetPath), 'images', path.basename(assetPath));
return assetPath;
},
// OPTIONAL: defaults to including everything
// can be a string, a RegExp, or an array of strings and RegExps
include: [/\.js$/],
// OPTIONAL: defaults to excluding nothing
// can be a string, a RegExp, or an array of strings and RegExps
// if a file matches both include and exclude, exclude takes precedence
exclude: [/\.png$/, /\.html$/],
// yazl Options
// OPTIONAL: see https://github.com/thejoshwolfe/yazl#addfilerealpath-metadatapath-options
fileOptions: {
mtime: new Date(),
mode: 0o100664,
compress: true,
forceZip64Format: false,
},
// OPTIONAL: see https://github.com/thejoshwolfe/yazl#endoptions-finalsizecallback
zipOptions: {
forceZip64Format: false,
},
})
]
};
```