最近写了一个React和Vue的自动发布工具,可以将build或者dist文件夹上传到Server目录下实现一键发布说明使用FTPServer将ReactJSApp和VueJSApp的构建文件发布到Web服务器的目标目录。优点如下:没有残留的历史文件。发布时会生成一个当前版本的目录json。当前版本不再引用的文件上传后将被删除。优化文件的发布顺序。为了防止在线用户访问你的web应用,最后会上传并安装指定的入口文件(eg:index.html)npmiweb-app-ftp-publishExample//publish.jsconstPublisher=require(`web-app-ftp-publish`);constpath=require('路径');letpublisher=newPublisher({ftp:{host:"",port:"",user:"",password:"",},//必填。ftp配置对象。配置文件链接在这里:https://github.com/mscdex/node-FTP#methodstargetPath:path.resolve(__dirname+"/./build"),//必填.build目录的绝对路径(build或dist文件夹路径)indexFileName:"index.html",//可选。构建目录的索引文件名。默认'index.html'destPath:"/react/build",//Ftp目标目录。default"/',ftp服务器根目录catalogFileName:"build-dir-catalog"//可选.catalogjson文件名.default'catalog.json'});publisher.resume();//package.json"scripts":{"start":"nodescripts/start.js","build":"nodescripts/build.js","publish":"node[YOURPATH]/publish.js"//添加发布脚本命令},//Terminalnpmrunpublishconfigurationftp-required.ftp配置对象.配置文件链接在这里:https://github.com/mscdex/nod...targetPath-Required.build文件夹的项目路径(build或dist)indexfilename-可选。构建文件夹(build或dist)索引文件名。默认index.html。destPath-可选选择。将文件上传到Ftp的文件夹。默认ftp服务器根目录。catalogFileName-可选。目录json文件名。默认“catalog.json”方法恢复,开始上传项目地址Github:https://github.com/breakeris/...NPM:https://www.npmjs.com/package...
