Appendix A. The Gatsby CLI
The Gatsby CLI is the primary means of setting up, developing, and running a Gatsby application, including within a local development server and performing production builds.
Gatsby Cheat Sheet
First, install the global executable:
$npminstall-ggatsby-cli
Execute gatsby --help for a full list of available commands and options.
Common CLI Commands
Here’s a quick rundown of the commands you’ll use most often, covered in more detail in “Gatsby CLI Commands”:
gatsby new my-gatsby-site-name- Create a new local Gatsby site using the default starter.
gatsby develop-
Start the Gatsby development server, optionally with the flags
-Hand--host.Set the host. Defaults to
localhost:-p,--port.Set the port. Defaults to
8000:-o,--open.Open the site in the default browser:
-S,--https.Use HTTPS.
gatsby build-
Compile your application and prepare it for deployment, optionally with the flag
--prefix-paths.Build the site with link paths prefixed (after setting
pathPrefixin gatsby-config.js):--no-uglify.Build the site without uglifying JavaScript bundles (for debugging):
--open-tracing-config-file.Enable use of an OpenTracing-compatible configuration file.
gatsby serve-
Serve the production build for testing, optionally with the flags
-Hand--host.Set host. Defaults to
localhost:-p,--port.Set port. Defaults to
9000:-o,--open.Open the site in the default browser:
--prefix-paths.Serve the site with link paths prefixed (if built with
pathPrefix ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access