What is gatsby-cli?
The gatsby-cli npm package is a command-line interface tool for creating, developing, and managing Gatsby sites. It provides a range of commands to streamline the development process, from setting up new projects to deploying them.
What are gatsby-cli's main functionalities?
Create a new Gatsby site
This command initializes a new Gatsby site in a directory called 'my-gatsby-site'. It sets up the necessary files and dependencies to get started with a Gatsby project.
gatsby new my-gatsby-site
Develop a Gatsby site
This command starts a local development server and watches for changes in your Gatsby site. It provides hot-reloading and a GraphQL data layer for building and testing your site locally.
gatsby develop
Build a Gatsby site
This command generates a production-ready static site. It compiles your site into static files that can be deployed to any web server.
gatsby build
Serve a Gatsby site
This command starts a local server to serve the production build of your site. It is useful for testing the final output before deploying it.
gatsby serve
Clean Gatsby cache
This command deletes the .cache and public directories. It is useful for troubleshooting and ensuring a clean build environment.
gatsby clean
Other packages similar to gatsby-cli
create-react-app
Create React App is a command-line tool to set up a new React project with a single command. It provides a similar experience to gatsby-cli but is focused on React applications rather than static site generation.
next
Next.js is a React framework that provides a CLI for creating and managing projects. It offers server-side rendering and static site generation, making it a versatile alternative to Gatsby for building modern web applications.
vue-cli
Vue CLI is a command-line tool for scaffolding Vue.js projects. It offers a similar set of features to gatsby-cli but is tailored for Vue.js applications, including project creation, development server, and build commands.
gatsby-cli
Gatsby command line tool.
Let's you create new Gatsby sites using Gatsby starters
Also let's you run commands on sites. The tool runs code from the gatsby
package
installed locally.
Install
npm install --global gatsby-cli
How to use
Run gatsby --help
for full help.
New
gatsby new gatsby-site
See the Gatsby starters docs for more
Develop
At the root of a Gatsby site run gatsby develop
to start the Gatsby development server.
Build
At the root of a Gatsby site run gatsby build
to do a production build of a site.
Serve
At the root of a Gatsby site run gatsby serve
to serve the production build of the site for testing.