You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Updated for Zeit Now V2
* Fixed styling issue
* Added additional hint for router mode set to history
* Update docs/guide/deployment.md
Co-Authored-By: Natalia Tepluhina <[email protected]>
(cherry picked from commit 55dc287)
Copy file name to clipboardExpand all lines: docs/guide/deployment.md
+42-18Lines changed: 42 additions & 18 deletions
Original file line number
Diff line number
Diff line change
@@ -265,6 +265,8 @@ Please refer to the [Firebase Documentation](https://firebase.google.com/docs/ho
265
265
266
266
### Now
267
267
268
+
This example uses the latest Now platform version 2.
269
+
268
270
1. Install the Now CLI globally:
269
271
270
272
```bash
@@ -276,35 +278,57 @@ npm install -g now
276
278
```json
277
279
{
278
280
"name": "my-example-app",
279
-
"type": "static",
280
-
"static": {
281
-
"public": "dist",
282
-
"rewrites": [
283
-
{
284
-
"source": "**",
285
-
"destination": "/index.html"
286
-
}
287
-
]
288
-
},
289
-
"alias": "vue-example",
290
-
"files": [
291
-
"dist"
292
-
]
281
+
"version": 2,
282
+
"builds": [
283
+
{ "src": "dist/**", "use": "@now/static" }
284
+
],
285
+
"routes": [
286
+
{ "src": "/(.*)", "dest": "dist/$1" }
287
+
],
288
+
"alias": "vue-example"
293
289
}
294
290
```
295
-
296
-
You can further customize the static serving behavior by consulting [Now's documentation](https://zeit.co/docs/deployment-types/static).
291
+
292
+
In case you want to deploy an application with router mode set to history, the config file should look like the following (if you have different folder names, update your config accordingly):
293
+
```json
294
+
{
295
+
"name": "my-example-app",
296
+
"version": 2,
297
+
"builds": [
298
+
{
299
+
"src": "dist/**",
300
+
"use": "@now/static"
301
+
}
302
+
],
303
+
"routes": [
304
+
{
305
+
"src": "/(js|css|img)/(.*)",
306
+
"dest": "/dist/$1/$2"
307
+
},
308
+
{
309
+
"src": "/favicon.ico",
310
+
"dest": "/dist/favicon.ico"
311
+
},
312
+
{
313
+
"src": "/(.*)",
314
+
"dest": "/dist"
315
+
}
316
+
],
317
+
"alias": "vue-example"
318
+
}
319
+
```
320
+
This additional config is required in order to avoid issues when directly deep-linking to a specific page (e.g. when opening `my-example-app.now.sh/some-subpage`, you would be presented with a 404 error otherwise).
297
321
298
322
3. Adding a deployment script in`package.json`:
299
323
300
324
```json
301
-
"deploy": "npm run build && now && now alias"
325
+
"deploy": "npm run build && now --target production"
302
326
```
303
327
304
328
If you want to deploy publicly by default, you can change the deployment script to the following one:
305
329
306
330
```json
307
-
"deploy": "npm run build && now --public && now alias"
331
+
"deploy": "npm run build && now --target production --public"
308
332
```
309
333
310
334
This will automatically point your site's alias to the latest deployment. Now, just run `npm run deploy` to deploy your app.
0 commit comments