|
8 | 8 |
|
9 | 9 | ### 本地预览
|
10 | 10 |
|
11 |
| -`dist` 目录需要启动一个 HTTP 服务器来访问,所以以 `file://` 协议直接打开 `dist/index.html` 是不会工作的。在本地预览生产环境构建最简单的方式就是使用一个 Node.js 静态文件服务器,例如 [serve](https://github.com/zeit/serve): |
| 11 | +`dist` 目录需要启动一个 HTTP 服务器来访问 (除非你已经将 `baseUrl` 配置为了一个相对的值),所以以 `file://` 协议直接打开 `dist/index.html` 是不会工作的。在本地预览生产环境构建最简单的方式就是使用一个 Node.js 静态文件服务器,例如 [serve](https://github.com/zeit/serve): |
12 | 12 |
|
13 | 13 | ``` bash
|
14 | 14 | npm install -g serve
|
@@ -168,7 +168,7 @@ Firebase will ask some questions on how to setup your project.
|
168 | 168 |
|
169 | 169 | {
|
170 | 170 | "hosting": {
|
171 |
| - "public": "app" |
| 171 | + "public": "dist" |
172 | 172 | }
|
173 | 173 | }
|
174 | 174 | ```
|
@@ -206,7 +206,45 @@ Please refer to the [Firebase Documentation](https://firebase.google.com/docs/ho
|
206 | 206 |
|
207 | 207 | ### Now
|
208 | 208 |
|
209 |
| -> TODO | Open to contribution. |
| 209 | +1. Install the Now CLI globally: `npm install -g now` |
| 210 | + |
| 211 | +2. Add a `now.json` file to your project root: |
| 212 | + |
| 213 | + ```json |
| 214 | + { |
| 215 | + "name": "my-example-app", |
| 216 | + "type": "static", |
| 217 | + "static": { |
| 218 | + "public": "dist", |
| 219 | + "rewrites": [ |
| 220 | + { |
| 221 | + "source": "**", |
| 222 | + "destination": "/index.html" |
| 223 | + } |
| 224 | + ] |
| 225 | + }, |
| 226 | + "alias": "vue-example", |
| 227 | + "files": [ |
| 228 | + "dist" |
| 229 | + ] |
| 230 | + } |
| 231 | + ``` |
| 232 | + |
| 233 | + You can further customize the static serving behavior by consulting [Now's documentation](https://zeit.co/docs/deployment-types/static). |
| 234 | +
|
| 235 | +3. Adding a deployment script in `package.json`: |
| 236 | +
|
| 237 | + ```json |
| 238 | + "deploy": "npm run build && now && now alias" |
| 239 | + ``` |
| 240 | +
|
| 241 | + If you want to deploy publicly by default, you can change the deployment script to the following one: |
| 242 | +
|
| 243 | + ```json |
| 244 | + "deploy": "npm run build && now --public && now alias" |
| 245 | + ``` |
| 246 | +
|
| 247 | + This will automatically point your site's alias to the latest deployment. Now, just run `npm run deploy` to deploy your app. |
210 | 248 |
|
211 | 249 | ### Stdlib
|
212 | 250 |
|
@@ -239,3 +277,36 @@ Then cd into the `dist/` folder of your project and then run `surge` and follow
|
239 | 277 | ```
|
240 | 278 |
|
241 | 279 | Verify your project is successfully published by Surge by visiting `myawesomeproject.surge.sh`, vola! For more setup details such as custom domains, you can visit [Surge's help page](https://surge.sh/help/).
|
| 280 | +
|
| 281 | +### Bitbucket Cloud |
| 282 | +
|
| 283 | +1. As described in the [Bitbucket documentation](https://confluence.atlassian.com/bitbucket/publishing-a-website-on-bitbucket-cloud-221449776.html) you need to create a repository named exactly `<USERNAME>.bitbucket.io`. |
| 284 | +
|
| 285 | +2. It is possible to publish to a subfolder of the main repository, for instance if you want to have multiple websites. In that case set correct `baseUrl` in `vue.config.js`. |
| 286 | +
|
| 287 | + If you are deploying to `https://<USERNAME>.bitbucket.io/`, you can omit `baseUrl` as it defaults to `"/"`. |
| 288 | +
|
| 289 | + If you are deploying to `https://<USERNAME>.bitbucket.io/<SUBFOLDER>/`, set `baseUrl` to `"/<SUBFOLDER>/"`. In this case the directory structure of the repository should reflect the url structure, for instance the repository should have a `/<SUBFOLDER>` directory. |
| 290 | +
|
| 291 | +3. Inside your project, create `deploy.sh` with the following content and run it to deploy: |
| 292 | +
|
| 293 | + ``` bash{13,20,23} |
| 294 | + #!/usr/bin/env sh |
| 295 | +
|
| 296 | + # abort on errors |
| 297 | + set -e |
| 298 | +
|
| 299 | + # build |
| 300 | + npm run build |
| 301 | +
|
| 302 | + # navigate into the build output directory |
| 303 | + cd dist |
| 304 | +
|
| 305 | + git init |
| 306 | + git add -A |
| 307 | + git commit -m 'deploy' |
| 308 | +
|
| 309 | + git push -f [email protected]:<USERNAME>/<USERNAME>.bitbucket.io.git master |
| 310 | +
|
| 311 | + cd - |
| 312 | + ``` |
0 commit comments