惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

云风的 BLOG
云风的 BLOG
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
IT之家
IT之家
Recent Announcements
Recent Announcements
B
Blog
D
Docker
V
V2EX
GbyAI
GbyAI
L
LangChain Blog
博客园 - Franky
U
Unit 42
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
博客园 - 【当耐特】
Google DeepMind News
Google DeepMind News
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Vercel News
Vercel News
博客园_首页
D
DataBreaches.Net
人人都是产品经理
人人都是产品经理
Y
Y Combinator Blog
量子位
Blog — PlanetScale
Blog — PlanetScale
罗磊的独立博客

Dr34m's Blog

I Expect You To Die(我希望你死) 1,2,3 完整中文攻略 Linux换国内源 && docker安装 && 换加速镜像 Vue3 + Element-Plus 极简速查 随笔 pyinstaller打包的程序执行报错Failed to extract xxxx decompression resulted in return code -1 taoSync排除项简易教程 apscheduler的cron配置项 如何在绿联NAS中使用TaoSync同步我的文件到各个网盘 GB28181抓包记录 JS计算字节大小,把字节转换为KB/MB/GB/TB等 在Python中使用onvif管理摄像头,包括设备发现,获取RTSP地址,获取设备信息,截图,云台控制与缩放,设置时间 内网穿透工具frp快速使用 CentOS 7.9 安装基础开发环境jdk redis nacos nginx mysql Pyinstaller 逆向 VUE实现复制与粘贴_获取剪切板内容 Electron + xterm.js + node-pty + vue 实现本地终端 child_process exec 中文乱码 Windows&Linux 解决方法 yum 更新 gcc CentOS安装并使用conda 将fluid主题博客的静态资源由第三方改为本地存储 一个上手即用的通用公众号/小程序/h5/app框架 python批量转化doc到docx SpringBoot单元测试注入空指针 TensorFlow 预测出现NaN的一种可能以及解决方法 随笔 python归一化数据 windows下python安装sasl遇到的问题及解决 将对象List中的某个字段放到新的List中[转载] Python http.server 本地服务支持跨域 TensorFlow入门
编写bat脚本实现对vue项目构建并压缩
Dr3@m · 2023-09-07 · via Dr34m's Blog

目标

编写bat脚本自动完成代码更新、构建、压缩为日期命名的压缩包

实现

一、准备

1、npm install

通常npm install只要执行一次,就不写在脚本里了,所以需要预先执行过一次npm install

2、压缩工具

windows下需要一个压缩工具来实现命令压缩

官网下载安装文件,安装完成后把安装目录的7z.exe7z.dll复制到C:\Windows\System32目录下,如果不需要7z就可以卸载了

二、脚本

项目根目录新建打包.bat文件,并编写如下

1
2
3
4
5
6
7
8
9
10
11
12
set "curr_date=%date%"
set "yy=%curr_date:~0,4%"
set "mn=%curr_date:~5,2%"
set "dd=%curr_date:~8,2%"
set "curr_time=%time%"
if %curr_time:~0,2% leq 9 (set hh=0%curr_time:~1,1%) else (set hh=%curr_time:~0,2%)
set "mm=%curr_time:~3,2%"
set "ss=%curr_time:~6,2%"

set "newname=%yy%%mn%%dd%-%hh%%mm%%ss%.zip"

git pull && npm run build && 7z a %newname% dist

上边的名称可以自定义修改为自己想要的,例如改为newname=%yy%%mn%%dd%-%hh%%mm%%ss%-prod.zip

如果想要压缩包根目录不是dist目录,直接是dist目录中的文件,最后一行可以改为

1
git pull && npm run build && cd dist && 7z a %newname% **