How to deploy Vue app?

2019-01-10 07:48发布

What should I do after developing a Vue app with vue-cli?

In Angular there was some command that bundle all the scripts into one single script, and then these files are sent to host.

Is there something the same in Vue?

9条回答
倾城 Initia
2楼-- · 2019-01-10 08:46

if you used vue-cli and webpack when you created your project.

you can use just

npm run build command in command line, and it will create dist folder in your project. Just upload content of this folder to your ftp and done.

查看更多
乱世女痞
3楼-- · 2019-01-10 08:46

I think you can use vue-cli

If you are using Vue CLI along with a backend framework that handles static assets as part of its deployment, all you need to do is making sure Vue CLI generates the built files in the correct location, and then follow the deployment instruction of your backend framework.

If you are developing your frontend app separately from your backend - i.e. your backend exposes an API for your frontend to talk to, then your frontend is essentially a purely static app. You can deploy the built content in the dist directory to any static file server, but make sure to set the correct baseUrl

查看更多
做个烂人
4楼-- · 2019-01-10 08:49

One way to do this without using VUE-CLI is to bundle the all script files into one fat js file and then reference that big fat javascript file into main template file.

I prefer to use webpack as a bundler and create a webpack.conig.js in the root directory of project. All the configs such as entry point, output file, loaders, etc.. are all stored in that config file. After that, I add a script in package.json file that uses webpack.config.js file for webpack configs and start watching files and create a Js bundled file into mentioned location in webpack.config.js file.

查看更多
登录 后发表回答