Skip to content

Commit 2ca32e5

Browse files
timothyisDSchau
authored andcommitted
Update "Deploying with Now" Guide (#10390)
* Update the Now guide to use Now v2 * Add reference * Address review comments * Update docs/docs/deploying-to-now.md Co-Authored-By: timothyis <[email protected]> * Update docs/docs/deploying-to-now.md Co-Authored-By: timothyis <[email protected]> * Update docs/docs/deploying-to-now.md Co-Authored-By: timothyis <[email protected]> * Update docs/docs/deploying-to-now.md Co-Authored-By: timothyis <[email protected]> * Update deploying-to-now.md
1 parent 668aa9f commit 2ca32e5

File tree

1 file changed

+57
-14
lines changed

1 file changed

+57
-14
lines changed

docs/docs/deploying-to-now.md

+57-14
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,79 @@
22
title: Deploying to Now
33
---
44

5-
In order to deploy your Gatsby project using [Now](https://zeit.co/now), you can do the following:
5+
[ZEIT Now](https://zeit.co/now) is a [cloud platform for serverless deployment](https://zeit.co/docs/v2/getting-started/introduction-to-now/) that you can use to deploy your Gatsby projects and [alias them](https://zeit.co/docs/v2/domains-and-aliases/aliasing-a-deployment/) to your personal domain or a free `.now.sh` suffixed URL.
66

7-
1. Install the Now CLI
7+
This guide will show you how to get started in a few quick steps:
88

9-
`npm install -g now`
9+
## Step 1: Getting Started with Gatsby
1010

11-
2. Run `gatsby build` at the root of your project.
11+
If you haven't already [set up a Gatsby project](https://www.gatsbyjs.org/docs/quick-start) you can do so by first installing Gatsby globally:
1212

13-
3. Run `now` inside `public/`. This will upload your project to the cloud.
13+
```shell
14+
npm install --global gatsby-cli
15+
```
16+
17+
Then generate a project with the following command:
1418

15-
For large project sizes, it is better to install a Node server package (such as `serve`, or `http-server`):
19+
```shell
20+
gatsby new <your project name>
21+
```
1622

17-
1. Install a Node server package
23+
## Step 2: Getting Now
1824

19-
`npm install --save serve`
25+
You can use Now by installing [Now Desktop](https://zeit.co/docs/v2/getting-started/installation/#now-desktop), which also installs Now CLI and keeps it up-to-date automatically.
2026

21-
2. Add a `start` script to your `package.json` file. This is what Now will use to run your application:
27+
To install Now CLI quickly with npm, use the following:
28+
29+
```shell
30+
npm install -g now
31+
```
32+
33+
## Step 3: Preparing to Deploy
34+
35+
With Now CLI installed, we can go on to deploy our previously setup Gatsby project by first creating a `now.json` file with the following contents:
36+
37+
```json:title=now.json
38+
{
39+
"version": 2,
40+
"name": "my-gatsby-project",
41+
"builds": [
42+
{
43+
"src": "package.json",
44+
"use": "@now/static-build",
45+
"config": { "distDir": "public" }
46+
}
47+
]
48+
}
49+
```
50+
51+
This `now.json` file will allow us to do several things, specifically:
52+
53+
- Use the [latest Now 2.0 version](https://zeit.co/blog/now-2) of [the platform](https://zeit.co/docs/v2/platform/overview/)
54+
- Set the project name to `my-gatsby-project`
55+
- Use the [@now/static-build builder](https://zeit.co/docs/v2/deployments/official-builders/static-build-now-static-build/) to take the `package.json` file as an entrypoint and use the `public` directory as the our content directory
56+
57+
The final step is to add a script to the `package.json` which will build our application:
2258

2359
```json:title=package.json
2460
{
2561
"scripts": {
26-
"start": "serve public/"
62+
...
63+
"now-build": "npm run build"
2764
}
2865
}
2966
```
3067

31-
3. Run `now` at the root of your Gatsby project, this will upload your project, run the `build` script, and then your `start` script.
68+
## Step 4: Deploying
3269

33-
To deploy a custom path, run `now` as:
70+
You can deploy your application by running the following in the root of the project directory, where the `now.json` is:
3471

35-
```shell
36-
$ now /usr/src/project
72+
```bash
73+
now
3774
```
75+
76+
That's all! Your application will now deploy, and you will receive a link similar to the following: https://my-gatsby-project-fhcc9hnqc.now.sh/
77+
78+
## References:
79+
80+
- [Deploying Gatsby with Now](https://zeit.co/examples/gatsby/)

0 commit comments

Comments
 (0)