简体   繁体   English

如何自动部署简单的 Vue WebApp(不需要服务器)? (即使用 vue 的简单构建链)

[英]How to automate deploy of simple Vue WebApp (no server required)? (i.e. simple build chain with vue)

I have written a small Vue app and have been looking for a nice way to automate its deployment, ie call lint -> test -> build -> upload to some web space (stage and /or production) (sftp).我编写了一个小型 Vue 应用程序,并且一直在寻找一种自动化部署的好方法,即调用 lint -> 测试 -> 构建 -> 上传到某个网络空间(阶段和/或生产)(sftp)。 Basically a simple CI/CD pipeline.基本上是一个简单的 CI/CD 管道。

I looked a task runners such as grunt (seems to be a bit outdated and the docs didn't help me much) and gulp (see also this answer ) and also thought of defining a npm script.我查看了诸如 grunt(似乎有点过时,文档对我帮助不大)和 gulp(另请参阅此答案)之类的任务运行程序,并且还想过定义一个 npm 脚本。 CI tools such as Jenkins seem to be a bit oversized with some work to setup.像 Jenkins 这样的 CI 工具似乎有点过大,需要进行一些设置。

The npm script would probably be the simples solution, especially as I could simply chain lint / test / build: npm 脚本可能是最简单的解决方案,特别是因为我可以简单地链接 lint / test / build:

{
  "scripts": {
    "build": "vue-cli-service build --modern",
    "lint": "vue-cli-service lint",
    "prettier": "prettier --write src/**/*.{ts,js,vue,css,less,scss,html,json,md} public/**/*.{ts,js,vue,css,less,scss,html,json,md} test/**/*.{js,vue,css,less,scss,html,json,md} build/*.js",
    "deploy": "# ...?",
    "pipeline": "yarn lint && yarn prettier && yarn test && yarn build && yarn deploy"
  },

However, I've no good idea yet for an easy way to deploy the build to my web server.但是,对于将构建部署到我的 Web 服务器的简单方法,我还没有什么好主意。 For grunt I found some tasks that might fit ( grunt-rsync , grunt-sftp-deploy ).对于 grunt,我发现了一些可能适合的任务( grunt-rsyncgrunt-sftp-deploy )。 But grunt doesn't seem to be the first choice nowadays.但是现在 grunt 似乎不是首选。

Does anyone have any recommendations or suggestions?有没有人有任何建议或建议?

Additional info: I'm using Windows and I don't want to publish my source (in this case) on github.附加信息:我使用的是 Windows,我不想在 github 上发布我的源代码(在这种情况下)。

The easiest way to deploy static site is to use pages.github.com - just push your build in github repo.部署静态站点的最简单方法是使用 pages.github.com - 只需在 github 存储库中推送您的构建。

Another simple (Mega simple) service is netlify - just install it with npm install netlify-cli -g .另一个简单(超级简单)的服务是netlify - 只需使用npm install netlify-cli -g安装它。 Details in docs文档中的详细信息

But if you need better CI you don't need to search "vue deploy', you need any CI service from github, bitbucket, gitlab, etc. For example - easy introduction by circleci但是如果你需要更好的 CI,你不需要搜索“vue deploy”,你需要来自 github、bitbucket、gitlab 等的任何 CI 服务。例如 - circleci 的简单介绍


Back to your question - do you use linux/mac or windows?回到你的问题——你使用 linux/mac 还是 windows? It's very simple on linux, just use command like scp from/local/dir to@remote/dir .这在 linux 上非常简单,只需使用scp from/local/dir to@remote/dir On windows you maybe should try some nodejs alternatives like snippet from this answer在 Windows 上,您可能应该尝试一些 nodejs 替代方案,例如此答案中的片段

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM