Skip to content

Commit 486ca18

Browse files
committed
docs: basic deployment notes
1 parent 445d96e commit 486ca18

File tree

1 file changed

+58
-5
lines changed

1 file changed

+58
-5
lines changed

docs/guide/deployment.md

Lines changed: 58 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,76 @@
11
# Deployment
22

3-
## GitHub Pages
3+
## General Guidelines
4+
5+
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.
6+
7+
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](../config/#baseurl).
8+
9+
### Previewing Locally
10+
11+
The `dist` directory is meant to be served by an HTTP server, so it will not work if you open `dist/index.html` directly over `file://` protocol. The easiest way to preview your production build locally is using a Node.js static file server, for example [serve](https://github.com/zeit/serve):
12+
13+
``` bash
14+
npm install -g serve
15+
# -s flag means serve it in Single-Page Application mode
16+
# which deals with the routing problem below
17+
serve -s dist
18+
```
19+
20+
### Routing with `history.pushState`
21+
22+
If you are using Vue Router in `history` mode, a simple static file server will fail. For example, if you used Vue Router with a route for `/todos/42`, the dev server has been configured to respond to `localhost:3000/todos/42` properly, but a simple static server serving a production build will respond with a 404 instead.
23+
24+
To fix that, you will need to configure your production server to fallback to `index.html` for any requests that do not match a static file. The Vue Router docs provides [configuration instructions for common server setups](https://router.vuejs.org/guide/essentials/history-mode.html).
25+
26+
### CORS
27+
28+
If your static frontend is deployed to a different domain from your backend API, you will need to properly configure [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS).
29+
30+
### PWA
31+
32+
If you are using the PWA plugin, your app must be served over HTTPS so that [Service Worker](https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API) can be properly registered.
33+
34+
## Platform Guides
35+
36+
### GitHub Pages
437

538
> TODO | Open to contribution.
639
7-
## GitLab Pages
40+
### GitLab Pages
841

942
> TODO | Open to contribution.
1043
11-
## Netlify
44+
### Netlify
1245

1346
> TODO | Open to contribution.
1447
1548
Also checkout [vue-cli-plugin-netlify-lambda](https://github.com/netlify/vue-cli-plugin-netlify-lambda).
1649

17-
## Amazon S3
50+
### Amazon S3
1851

1952
See [vue-cli-plugin-s3-deploy](https://github.com/multiplegeorges/vue-cli-plugin-s3-deploy).
2053

21-
## Heroku
54+
### Azure
55+
56+
> TODO | Open to contribution.
57+
58+
### Firebase
59+
60+
> TODO | Open to contribution.
61+
62+
### Now
63+
64+
> TODO | Open to contribution.
65+
66+
### Stdlib
67+
68+
> TODO | Open to contribution.
69+
70+
### Heroku
71+
72+
> TODO | Open to contribution.
73+
74+
### Surge
2275

2376
> TODO | Open to contribution.

0 commit comments

Comments
 (0)