如何实现vue-cli3项目打包后自动部署至服务器的操作流程?

更新于
2026-09-24 01:35:32
0阅读来源:SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计570个文字,预计阅读时间需要3分钟。

如何实现vue-cli3项目打包后自动部署至服务器的操作流程?

一、安装依赖bashscp2 npm install scp2 --save-dev

二、编写脚本创建一个名为 `upload.js` 的脚本(以下任选其一):

javascript// upload.js// 简略版const scp2=require('scp2');const client=new scp2.Client();client.scp('/dist', { recursive: true });

javascript// upload.js// 详细版const scp2=require('scp2');const fs=require('fs');const path=require('path');

const distPath=path.join(__dirname, 'dist');const client=new scp2.Client();

fs.readdir(distPath, (err, files)=> { if (err) throw err;

files.forEach(file=> { const filePath=path.join(distPath, file); client.scp(filePath, { recursive: true }); });});

三、配置确保 `use strict` 和 `scp2` 引用位于 `package.json` 平级。

阅读全文

本文共计570个文字,预计阅读时间需要3分钟。

如何实现vue-cli3项目打包后自动部署至服务器的操作流程?

一、安装依赖bashscp2 npm install scp2 --save-dev

二、编写脚本创建一个名为 `upload.js` 的脚本(以下任选其一):

javascript// upload.js// 简略版const scp2=require('scp2');const client=new scp2.Client();client.scp('/dist', { recursive: true });

javascript// upload.js// 详细版const scp2=require('scp2');const fs=require('fs');const path=require('path');

const distPath=path.join(__dirname, 'dist');const client=new scp2.Client();

fs.readdir(distPath, (err, files)=> { if (err) throw err;

files.forEach(file=> { const filePath=path.join(distPath, file); client.scp(filePath, { recursive: true }); });});

三、配置确保 `use strict` 和 `scp2` 引用位于 `package.json` 平级。

阅读全文