This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
network:webdev:gatsby [2021/07/18 10:02] zhwiki created |
network:webdev:gatsby [2021/07/18 22:38] (current) zhwiki [创建网站] |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Gatsby ====== | ====== Gatsby ====== | ||
+ | |||
+ | ===== 设置开发环境 ===== | ||
+ | |||
+ | Gatsby开发环境需要以下工具: | ||
+ | |||
+ | 1. Node.js (v12.13 or newer),其中包括npm包管理工具。 | ||
+ | |||
+ | 2. Git | ||
+ | | ||
+ | 3. Gatsby command line interface (CLI) (v3 or newer) | ||
+ | |||
+ | 全局安装gatsby命令行工具: | ||
+ | |||
+ | npm install -g gatsby-cli | ||
+ | | ||
+ | 检查是否正确安装: | ||
+ | |||
+ | gatsby --version | ||
+ | |||
+ | 查看帮助: | ||
+ | |||
+ | gatsby --help | ||
+ | | ||
+ | | ||
+ | 4.编辑器,如Visual Studio Code | ||
+ | |||
+ | ===== 创建网站 ===== | ||
+ | |||
+ | 1. 创建网站,运行gatsby命令行工具: | ||
+ | |||
+ | gatsby new | ||
+ | | ||
+ | 进入交互模式,创建网站。 | ||
+ | | ||
+ | 2. 编译网站,进入网站目录,运行编译工具,在本地编译网站: | ||
+ | |||
+ | npm run develop | ||
+ | | ||
+ | 3. 编译完成后,运行本地服务器: | ||
+ | |||
+ | gatsby develop | ||
+ | |||
+ | 此时,就可以在浏览器查看网站: | ||
+ | |||
+ | http://localhost:8000/ | ||
+ | |||
+ | 查看GraphiQL: | ||
+ | |||
+ | http://localhost:8000/___graphql | ||