centos7部署element-plus

  • centos7部署element-plus已关闭评论
  • 120 次浏览
  • A+
所属分类:linux技术
摘要

element-plus官网实在是太不稳定了,所以自己搭建了一套在本地,流程如下:环境安装

element-plus官网实在是太不稳定了,所以自己搭建了一套在本地,流程如下:

  1. 环境安装

    yum install node yum install npm node install -g pnpm 
  2. 从gitee拉取代码

     wget -P /opt/element-plus https://gitee.com/element-plus/element-plus/repository/archive/dev.zip  这代表代码的压缩文件被下载到了/opt/element-plus,解压此压缩包  cd /opt/element-plus  unzip dev.zip  得到了element-plus-dev源代码  cd /element-plus-dev/docs  安装依赖包  pnpm install 
  3. 打包发布

     先本地化一下语言,npm run gen-locale  再执行打包命令,npm run build  一般这个时候会报错,内存溢出,89691 ms: Mark-sweep 902.2 (931.7) -> 898.0 (932.4) MB, 511.4 / 0.1 ms  (average mu = 0.217, current mu = 0.132) allocation failure scavenge might not succeed  解决方法如下:npm install -g increase-memory-limit  在项目目录doc路径下:increase-memory-limit  然后再打包就可以完成,生产的dist文件夹在docs/.vitepress/dist  把这个dist挂到nginx,即可丝滑访问 
  4. 从gitee持续拉取,获取最新版文档
    (1) 编写shell脚本

     vim /opt/element-plus/deploy.sh  并添加执行权限,chmod 777 deploy.sh 
    #!/bin/bash  rm -rf /opt/element-plus/dev.zip rm -rf /opt/element-plus/element-plus-dev/ wget -P /opt/element-plus https://gitee.com/element-plus/element-plus/repository/archive/dev.zip cd /opt/element-plus unzip dev.zip cd /opt/element-plus/element-plus-dev/docs pnpm install increase-memory-limit npm run gen-locale npm run build 

    (2) 配置定时任务

     检查有没有crontab服务,`systemctl status crond.service`,  如果有,设置开机自动运行,`systemctl enable crond.service`  如果没有,`yum install crontabs`,完了也enable一下,开机自启动  配置定时拉取任务,`crontab -e`  `0 1 * * * sh /opt/element-plus/deploy.sh` 
  5. 完工
    遗憾就是发布出来的是英文版的,中文版还不知道怎么弄