bash
#!/bin/bash
WEB="web"
DIST="dist"
RED=\033[0:31m
GREEN=\033[0;32m
NC=\033[0m
#生产打包传参
BUILD="b"
if [ -e ${WEB} ];then
#删历史文件
rm -r ${WEB}
rm ${WEB}.zip
fi
#编辑文件
npm run build
#检查构建是否成功
if[ -e ${DIST} ];then
#改名
mv ${DIST} ${WEB}
#压缩
if[ "$1" == $BUILD ];then
zip −r ${WEB}.zip ${WEB}
fi
printf "${GREEN} success!!!!!!! ${NC}\n"
else
printf "${RED) failure!!!!!!!!!! ${NC}\n"
fi