Linux command
gatsby 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Create new site
gatsby new [site-name]
Create from starter
gatsby new [site-name] [https://github.com/user/starter]
Start development server
gatsby develop
Build for production
gatsby build
Serve production build
gatsby serve
Clean cache
gatsby clean
Show info
gatsby info
说明
gatsby is a React-based static site generator that creates fast, optimized websites using React components and GraphQL for data fetching. It combines modern web technologies with automatic code splitting, image optimization, and progressive enhancement. Gatsby builds static HTML at build time while maintaining React's interactive capabilities through hydration. The framework uses a rich plugin ecosystem for integrating CMSs, APIs, and services. GraphQL provides a unified data layer for querying content from multiple sources. The development server includes hot module replacement for rapid iteration, while production builds are optimized for performance with techniques like prefetching, lazy loading, and asset optimization.
参数
- -H, --host _host_
- Set host for develop/serve (default: localhost).
- -p, --port _port_
- Set port for develop/serve (default: 8000 for develop, 9000 for serve).
- -o, --open
- Open the site in the default browser.
- -S, --https
- Enable HTTPS for the development server.
- --inspect
- Open a debugging port for Node.js inspector.
- --prefix-paths
- Build/serve with path prefix (requires pathPrefix in gatsby-config).
- --no-uglify
- Build without uglifying JS bundles (for debugging).
- --profile
- Enable React profiling during build.
- --verbose
- Turn on verbose output.
- -C, --clipboard
- Copy environment info to clipboard (gatsby info).
FAQ
What is the gatsby command used for?
gatsby is a React-based static site generator that creates fast, optimized websites using React components and GraphQL for data fetching. It combines modern web technologies with automatic code splitting, image optimization, and progressive enhancement. Gatsby builds static HTML at build time while maintaining React's interactive capabilities through hydration. The framework uses a rich plugin ecosystem for integrating CMSs, APIs, and services. GraphQL provides a unified data layer for querying content from multiple sources. The development server includes hot module replacement for rapid iteration, while production builds are optimized for performance with techniques like prefetching, lazy loading, and asset optimization.
How do I run a basic gatsby example?
Run `gatsby new [site-name]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -H, --host _host_ do in gatsby?
Set host for develop/serve (default: localhost).