3.1 KiB
Deploying
The following guides are based on a few shared assumptions:
- You are placing your docs inside the
docsdirectory of your project; - You are using the default build output location (
.vuepress/dist); - VuePress is installed as a local dependency in your project, and you have setup the following npm scripts:
{
"scripts": {
"docs:build": "vuepress build docs"
}
}
GitHub Pages
-
Set correct
baseindocs/.vuepress/config.js.If you are deploying to
https://<USERNAME>.github.io/, you can omitbaseas it defaults to"/".If your are deploying to
https://<USERNAME>.github.io/<REPO>/, (i.e. your repository is athttps://github.com/<USERNAME>/<REPO>), setbaseto"/<REPO>/". -
Inside your project, create
deploy.shwith the following content (with highlighted lines uncommented appropriately) and run it to deploy:
#!/usr/bin/env sh
# abort on errors
set -e
# build
npm run docs:build
# navigate into the build output directory
cd docs/.vuepress/dist
# if you are deploying to a custom domain
# echo 'www.example.com' > CNAME
git init
git add -A
git commit -m 'deploy'
# if you are deploying to https://<USERNAME>.github.io
# git push -f git@github.com:<USERNAME>/<USERNAME>.github.io.git master
# if you are deploying to https://<USERNAME>.github.io/<REPO>
# git push -f git@github.com:<USERNAME>/<REPO>.git master:gh-pages
cd -
::: tip You can also run the above script in your CI setup to enable automatic deployment on each push. :::
GitLab Pages and GitLab CI
-
Set correct
baseindocs/.vuepress/config.js.If you are deploying to
https://<USERNAME or GROUP>.gitlab.io/, you can omitbaseas it defaults to"/".If your are deploying to
https://<USERNAME or GROUP>.gitlab.io/<REPO>/, (i.e. your repository is athttps://gitlab.com/<USERNAME>/<REPO>), setbaseto"/<REPO>/". -
Set
destin.vuepress/config.jstopublic. -
Create a file called
.gitlab-ci.ymlin the root of your project with the content below. This will build and deploy your site whenever you make changes to your content.
image: node:9.11.1
pages:
cache:
paths:
- node_modules/
script:
- npm install
- npm run docs:build
artifacts:
paths:
- public
only:
- master
Netlify
- On Netlify, setup up a new project from GitHub with the following settings:
- Build Command:
npm run docs:buildoryarn docs:build - Publish directory:
docs/.vuepress/dist
- Hit the deploy button!
Google Firebase
-
Make sure you have firebase-tools installed.
-
Create
firebase.jsonand.firebasercat the root of your project with the following content:firebase.json:{ "hosting": { "public": "./docs/.vuepress/dist", "ignore": [] } }.firebaserc:{ "projects": { "default": "<YOUR_FIREBASE_ID>" } } -
After running
yarn docs:buildornpm run docs:build, deploy with the commandfirebase deploy.