1. 安装插件gulp,gulp-scp2,cross-env,nprogress,
2. 根目录添加gulpfile.js
const gulp = require('gulp'),
scp = require('gulp-scp2'), //scp上传
devType = process.env.devType //上传环境判断
const scpOptions = {
host: '**.***.**.***',
username: 'root',
password: '****************',
dest: ''
}
switch (devType) {
case 'o': //生产
scpOptions.dest = '/www/wwwroot/test2';
break;
default: //默认test测试
scpOptions.dest = '/www/wwwroot/test2/test';
break;
}
//cmd显示上传路径
console.log(scpOptions.dest);
gulp.task('scp', function () {
return gulp.src('./dist/**').pipe(scp(scpOptions));
});