compressed-bundle
构建生成包完成后将包打包成zip和tar包的webapck插件
使用
npm i compressed-bundle
webpack.config.js
const CompressingFile = require("compressed-bundle")["compressed-bundle"];
module.exports = {
plugins: [
new CompressingFile([{
type:"zip",
path:path.resolve(__dirname,`./dist/`),
target:path.resolve(__dirname,"./app/"),
filename:`jwplugin`
},{
type:"tar",
path:path.resolve(__dirname,`./dist/`),
target:path.resolve(__dirname,"./app/"),
filename:`jwplugin`
}]),
]
}
生成app文件夹,包含jwplugin.zip、jwplugin.tar压缩包
参数
构造函数参数options: array|object
array用于生成多个压缩包
options item:
字段 | 含义 | 类型 | 必输 |
---|---|---|---|
type | 压缩包类型 tar|zip | string | 是 |
path | 需要打包的文件夹的绝对路径 | string | 否,默认文件输出目录(推荐输入,vue-cli等脚手架中可能会有bug) |
target | 压缩包输出绝对路径 | string | 是 |
filename | 压缩包名称 | string | 是 |
**注意:压缩包输出目录不可以是path子目录!比如输出目录是dist 压缩包目录就不可以是dist下的任意路径,可以是dist的同级目录或者上级目录都可以。 **
源代码:同级resource.js