sftp-uploader-webpack-plugin
v1.0.1
Published
[![npm][npm-image]][npm-url] [![GitHub last commit (branch)][last-commit-image]](#)
Downloads
4
Readme
SFTP uploader plugin for webpack
A webpack plugin to upload your build folder(s) to server by sftp.
NOTE: Node v12+ and webpack v4+ are supported.
Installation
npm i -D sftp-uploader-webpack-plugin
or
yarn add -D sftp-uploader-webpack-plugin
Usage
Webpack configuration webpack.config.ts
// import SftpUploader from 'sftp-uploader-webpack-plugin';
const SftpUploader = require('sftp-uploader-webpack-plugin');
// ...
const webpackConfig = {
// ...
plugins: [
// ...
...(!process.env.SFTP_REMOTE_HOST
? []
: [
new SftpUploader({
// ssh options
scp: {
host: process.env.SFTP_REMOTE_HOST,
...(process.env.SFTP_REMOTE_PORT && { port: +process.env.SFTP_REMOTE_PORT }),
username: process.env.SFTP_REMOTE_USER,
password: process.env.SFTP_REMOTE_PASSWORD,
// ... other `ssh2` options
},
remotePath: process.env.SFTP_REMOTE_PATH/* ! */,
// localPath: path.resolve(__dirname, 'dist'),
}),
]),
],
}
module.exports = webpackConfig;
Example .env
# SFTP
SFTP_REMOTE_HOST=localhost
SFTP_REMOTE_PORT=22
SFTP_REMOTE_USER=user
SFTP_REMOTE_PASSWORD=password
SFTP_REMOTE_PATH=/var/www/prod