# 部署 dist 到远程服务器
# 1. 说明
兼容:
- node.js ^12.0.0, 使用 2.4.1 版本
# 2. 使用
const path = require('path');
const FtpDeploy = require('ftp-deploy');
const ftpDeploy = new FtpDeploy();
const config = {
host: "192.168.1.100",
// 21 - ftp; 22 - sftp
port: 22,
user: "root",
password: "123456",
// dist 目录
localRoot: path.resolve(__dirname, '../dist'),
remoteRoot: "/home/nginx/www",
// this would upload everything except dot files
include: ["*", "**/*"],
exclude: [
"node_modules/**",
"node_modules/**/.*",
".git/**",
],
// delete ALL existing files at destination before uploading, if true
deleteRemote: true,
// Passive mode is forced (EPSV command is not sent)
forcePasv: true,
// use sftp or ftp
sftp: true,
};
ftpDeploy
.deploy(mergedConfig)
.then((res) => console.log('finished:', res))
.catch((err) => console.log(err));
上一篇: 下一篇:
本章目录