problem description
when deploying front-end projects, you can manually type: npm run build
build on the command line, and then manually enter the server address, directory, and password to the server
. It is very troublesome
whether you can write a script or something, and you only need to enter a command to complete the above actions
PS: projects are mostly built by vue-cli webpack templates
methods have been found. Thank you
this is the solution I found:
" simple configuration front-end project realizes that the files are automatically uploaded to the server after being packaged.
I have never used the gulp-sftp used in the article, and I don"t know where it is not configured. I usually upload it using scp, so instead of gulp-scp2, except for slight changes in the gulp configuration file, the rest is the same, paste the configuration:
const gulp = require("gulp")
const scp = require("gulp-scp2")
gulp.task("default", () => {
console.log("")
return gulp.src("./dist/**/*")
.pipe(scp({
host: "hostname",
username: "username",
password: "password",
dest: "/home/admin/",
watch: function(client) {
client.on("write", function(o) {
console.log("write %s", o.destination);
});
}
}))
.on("error", (err) => {
console.log(err)
})
.on("end", () => {
console.log("")
})
})
personal test is valid, gulp likes upupup