-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update "Deploying with Now" Guide #10390
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ad11ac7
Update the Now guide to use Now v2
timothyis 0eabb42
Add reference
timothyis b8fb781
Address review comments
timothyis 03155ce
Update docs/docs/deploying-to-now.md
DSchau 849e168
Update docs/docs/deploying-to-now.md
DSchau 49a3e52
Update docs/docs/deploying-to-now.md
DSchau fe3d083
Update docs/docs/deploying-to-now.md
DSchau 7a0b9fd
Update deploying-to-now.md
DSchau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,36 +2,79 @@ | |
title: Deploying to Now | ||
--- | ||
|
||
In order to deploy your Gatsby project using [Now](https://zeit.co/now), you can do the following: | ||
[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. | ||
|
||
1. Install the Now CLI | ||
This guide will show you how to get started in a few quick steps: | ||
|
||
`npm install -g now` | ||
## Step 1: Getting Started with Gatsby | ||
|
||
2. Run `gatsby build` at the root of your project. | ||
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: | ||
|
||
3. Run `now` inside `public/`. This will upload your project to the cloud. | ||
```shell | ||
npm install --global gatsby-cli | ||
``` | ||
|
||
Then generate a project with the following command: | ||
|
||
For large project sizes, it is better to install a Node server package (such as `serve`, or `http-server`): | ||
```shell | ||
gatsby new <your project name> | ||
``` | ||
|
||
1. Install a Node server package | ||
## Step 2: Getting Now | ||
|
||
`npm install --save serve` | ||
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. | ||
|
||
2. Add a `start` script to your `package.json` file. This is what Now will use to run your application: | ||
To install Now CLI quickly with npm, use the following: | ||
|
||
```shell | ||
npm install -g now | ||
``` | ||
|
||
## Step 3: Preparing to Deploy | ||
|
||
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: | ||
|
||
```json:title=now.json | ||
{ | ||
"version": 2, | ||
"name": "my-gatsby-project", | ||
"builds": [ | ||
{ | ||
"src": "package.json", | ||
"use": "@now/static-build", | ||
"config": { "distDir": "public" } | ||
} | ||
] | ||
} | ||
``` | ||
|
||
This `now.json` file will allow us to do several things, specifically: | ||
|
||
- Use the [latest Now 2.0 version](https://zeit.co/blog/now-2) of [the platform](https://zeit.co/docs/v2/platform/overview/) | ||
- Set the project name to `my-gatsby-project` | ||
- 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 | ||
|
||
The final step is to add a script to the `package.json` which will build our application: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. *your application |
||
|
||
```json:title=package.json | ||
{ | ||
"scripts": { | ||
"start": "serve public/" | ||
... | ||
"now-build": "npm run build" | ||
jgierer12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
``` | ||
|
||
3. Run `now` at the root of your Gatsby project, this will upload your project, run the `build` script, and then your `start` script. | ||
## Step 4: Deploying | ||
|
||
To deploy a custom path, run `now` as: | ||
You can deploy your application by running the following in the root of the project directory, where the `now.json` is: | ||
|
||
```shell | ||
$ now /usr/src/project | ||
```bash | ||
now | ||
``` | ||
|
||
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/ | ||
|
||
## References: | ||
|
||
- [Deploying Gatsby with Now](https://zeit.co/examples/gatsby/) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this at the root of the project?