hx-zip-plugin
v1.1.0
Published
内部利用zip的压缩能力,生成需要部署的zip静态资源文件和zip压缩html文件
Downloads
9
Readme
支持配置需要认定为静态资源的文件夹,exp:
// 默认配置如下,基本可不写options参数
{
static: ['js', 'css', 'fonts', 'img'], // 非必填项
prefix: '', // 非必填项,文件路径前缀,例如父文件名(例如2022,2023等活动页资源路径)
projectName: '' // 非必填项,项目名(一般会根据你当前项目名默认读取,如上线地址中的项目名与本地项目名不符时,需指定,其他情况可不填)
}
命令行工具安装
npm install hx-zip-plugin -D
vue.config.js的配置引入方式
const HxZipPlugin = require('hx-zip-plugin');
// 1. 简单配置
chainWebpack: config => {
config.
...
.end()
.plugin('hx-zip', {})
.use(HxZipPlugin)
.end()
...
// 2. 复杂配置(需配置可配置项情况下)
chainWebpack: config => {
config.
...
.end()
.plugin('hx-zip', {})
.use(HxZipPlugin)
.tap(() => ([{
prefix: '2022', // 2022年项目,并且要与其他年份项目区分开,防止静态资源重复出现覆盖情况下使用
static: ['js', 'css', 'fonts', 'img'],// (非必填)需要放入静态资源的文件夹名称(基本不用配置,除特殊情况下配置例如:比默认资源数组中资源多的情况下配置)
}]))
.end()
...
老项目配置(一般在webpack.common.config.js中配置)
const HxZipPlugin = require('hx-zip-plugin');
new HxZipPlugin({
prefix: '', // 非必填
static: ['js', 'css', 'fonts', 'img'] // 非必填
});
新增选项mode
- 可选值
difficult
(默认配置) - 'easy' 需添加,添加后仅对应的输出文件会生成zip
fix问题
v1.0.8
fix: 路径区分mac和windows @zhangbei