After vue package automatically upload files to the server, SCP2 package upload plugin

Vue done a few small projects, we must manually upload files to the server via FTP the package after each package,

After the trouble to eat, to learn a little package automatically upload tool, SCP2. SCP2 below the record about how to configure and use:

1, the installation:

$ npm install scp2 -g

Note: -g is a global installed, but when I use myself, when global installation configuration does not take effect (the specific cause is unknown, there is no detailed testing,) if the problem can try local installation

2, the introduction of plug-in build / build.js file

var  client  = require (' scp2 ')

3, the final configuration: webpack (vue-cli) use:

Modifying the build folder build.js introduction scp2 add the following code below the package file

     // 部署上线
    client.scp('本地目录', {
      host: '服务器Ip',
      username: '账号',
      password: '密码',
      path: '服务器端目录'
    }, function (err) {
      if (err) {
        console.log(err)
      } else {
        console.log('文件上传完毕!\n')
      }
    })

Scp2 port 22 is used, so use the root account and server root password

Published 18 original articles · won praise 10 · views 50000 +

Guess you like

Origin blog.csdn.net/a350110085/article/details/82758977