Skip to content

Commit c6cab26

Browse files
ivansiederNataliaTepluhina
authored andcommitted
Updated for Zeit Now V2 (#4232)
* 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)
1 parent c4daac6 commit c6cab26

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

docs/guide/deployment.md

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ Please refer to the [Firebase Documentation](https://firebase.google.com/docs/ho
265265

266266
### Now
267267

268+
This example uses the latest Now platform version 2.
269+
268270
1. Install the Now CLI globally:
269271

270272
```bash
@@ -276,35 +278,57 @@ npm install -g now
276278
```json
277279
{
278280
"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"
293289
}
294290
```
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).
297321

298322
3. Adding a deployment script in `package.json`:
299323

300324
```json
301-
"deploy": "npm run build && now && now alias"
325+
"deploy": "npm run build && now --target production"
302326
```
303327

304328
If you want to deploy publicly by default, you can change the deployment script to the following one:
305329

306330
```json
307-
"deploy": "npm run build && now --public && now alias"
331+
"deploy": "npm run build && now --target production --public"
308332
```
309333

310334
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

Comments
 (0)