1.2.3 • Published 4 years ago
vue-compress-upload-plugin v1.2.3
vue-compress-upload-plugin
1.2.x
本次版本升级支持多种压缩格式(zip/tar),更新的参数的属性名,使用
1.2.x
的小伙伴记得修改对应参数的属性名 增加了支持同时向多台服务器发布应用的功能、支持上传本地脚本到服务器执行下面展示的两种使用方法,视具体情况使用,一般情况下,我们只需要配置
serverList
或者是server
即可
const CompressUploadPlugin = require('vue-compress-upload-plugin');
// 第一种 有多台服务器需要发布应用
new CompressUploadPlugin({
serverList: [
{
host: 'xxx.xxx.xxx.xxx',
username: 'nginx',
password: 'xxx',
uploadPath: '/usr/local/nginx/webapp/dist.zip',
localCmdScriptPath:'c:/script/bin',
cmdScriptPath: '/usr/local/nginx/bin',
uploadAfterCmd: 'sh deploy-after.sh',
uploadBeforeCmd: 'sh deploy-before.sh'
},
{
host: 'xxx.xxx.xxx.xxx',
username: 'nginx',
password: 'xxx',
uploadPath: '/nginx/webapp/test/dist.zip',
}
],
compress:{
outPath: path.join(__dirname, '../static'),
srcPath: path.join(__dirname, '../dist')
},
serverOptions:{
uploadPath: '',
localCmdScriptPath:'',
cmdScriptPath: '',
uploadBeforeCmd: '',
uploadAfterCmd: '',
}
},{
stdout: false,
});
// 第二种 只有一台服务器需要发布应用
new CompressUploadPlugin({
server: {
host: 'xxx.xxx.xxx.xxx',
username: 'xxx',
password: 'xxx',
uploadPath: '/usr/local/nginx/webapp/dist.zip',
localCmdScriptPath: path.join(__dirname, '../bin'),
cmdScriptPath: '/usr/local/nginx/bin/',
uploadAfterCmd: 'sh deploy-after.sh',
uploadBeforeCmd: 'sh deploy-before.sh'
},
compress: {
filename: 'dist.zip',
outPath: path.join(__dirname, '../target'),
srcPath: path.join(__dirname, '../target/resources/home/static')
}
}, {
stdout: true,
showConfigInfo: true
});
参数说明
CompressUploadPlugin({server,serverList,serverOptions,zip},options)
serverList
server
Name | Type | Default | Description |
---|---|---|---|
host | string | | 主机名 | |
username | string | 当前项目根节点下的dist | 用户名 |
password | string | | 密码 | |
port | number | 22 | sftp 端口 |
uploadPath | string | | 文件上传路径 | |
localCmdScriptPath | string | | 本地脚本路径 | |
cmdScriptPath | string | | 脚本执行路径 | |
uploadBeforeCmd | string | | 文件上传成功前需要执行的脚本命令 | |
uploadAfterCmd | string | | 文件上传成功后需要执行的脚本命令 |
serverOptions
Name | Type | Default | Description |
---|---|---|---|
uploadPath | string | | 文件上传路径 | |
localCmdScriptPath | string | | 本地脚本路径 | |
cmdScriptPath | string | | 脚本执行路径 | |
uploadBeforeCmd | string | | 文件上传成功前需要执行的脚本命令 | |
uploadAfterCmd | string | | 文件上传成功后需要执行的脚本命令 |
compress
Name | Type | Default | Description |
---|---|---|---|
format | string | zip,tar,json | 压缩格式,不建议使用 json |
outPath | string | 当前项目根节点下的static | 压缩文件输出目录 |
srcPath | string | 当前项目根节点下的dist | 需要压缩的目录 |
filename | string | dist.zip | 压缩的文件名 |
options
Name | Type | Default | Description |
---|---|---|---|
stdout | boolean | false | 是否输出shell的输出信息 |
showConfigInfo | boolean | false | 是否输出插件的配置信息 |
这里提供一个Linux脚本案列
deploy-before.sh
cd /nginx/webapp/public
if [ ! -f "/nginx/webapp/public/dist.zip" ];then
echo "dist.zip文件不存在"
else
mv dist.zip dist_backups.zip
fi
deploy-after.sh
#!/bin/bash
cd /nginx/webapp/public
# 删除原静态资源目录
rm -rf dist
# 解压新的包
unzip dist.zip
ls -l
NOTE
1. 在打包的时候,请将指定的 `zipName` 排除用 `CopyWebpackPlugin` 排除在外,以避免不必要的性能开销
2. 请确保服务器和本地对应的目录存在
1.2.3
4 years ago
1.2.2
4 years ago
1.2.0
4 years ago
1.2.1
4 years ago
1.1.5
4 years ago
1.1.3-beta
5 years ago
1.1.2-beta
5 years ago
1.1.1-beta
5 years ago
1.1.0-beta
5 years ago
1.0.13
5 years ago
1.0.12-beta
5 years ago
1.0.11-beta
5 years ago
1.0.10-beta
5 years ago
1.0.9-beta
5 years ago
1.0.8-beta
5 years ago
1.0.7-beta
5 years ago
1.0.6-beta
5 years ago
1.0.5-beta
5 years ago
1.0.4
5 years ago
1.0.3
5 years ago
1.0.2
5 years ago
1.0.1
5 years ago
1.0.0
5 years ago