nx/docs/shared/next-plugin.md

77 lines
2.3 KiB
Markdown

# Gatsby Plugin
The Nx Plugin for Gatsby contains executors and generators for managing Gatsby applications and libraries within an Nx workspace. It provides:
- Scaffolding for creating, building, serving, linting, and testing Gatsby applications.
- Integration with building, serving, and exporting a Gatsby application.
- Integration with React libraries within the workspace.
## Installing the Gatsby Plugin
Installing the Gatsby plugin to a workspace can be done with the following:
```shell script
yarn add -D @nrwl/gatsby
```
```shell script
npm install -D @nrwl/gatsby
```
## Applications
Generating new applications can be done with the following:
```shell script
nx generate @nrwl/gatsby:application <name>
```
This creates the following app structure:
```treeview
myorg/
├── apps/
│   ├── myapp/
│   │   ├── src/
│   │   │   ├── pages/
│   │   │   │   ├── index.module.css
│   │   │   │   └── index.tsx
│   │   ├── jest.conf.js
│   │   ├── tsconfig.json
│   │   ├── tsconfig.app.json
│   │   ├── tsconfig.spec.json
│   │   └── .eslintrc.json
│   └── myapp-e2e/
│   │   ├── src/
│   │   │   ├── integrations/
│   │   │   │   └── app.spec.ts
│   │   │   ├── fixtures/
│   │   │   ├── plugins/
│   │   │   └── support/
│   │   ├── cypress.json
│   │   ├── tsconfig.e2e.json
│   │   └── .eslintrc.json
├── libs/
├── workspace.json
├── nx.json
├── package.json
├── tools/
├── tsconfig.json
└── .eslintrc.json
```
## See Also
- [Using Gatsby](https://www.gatsbyjs.com/docs/quick-start/)
## Executors / Builders
- [build](/{{framework}}/plugins/gatsby/executors/build) - Builds a Gatsby application
- [server](/{{framework}}/plugins/gatsby/executors/server) - Builds and serves a Gatsby application
## Generators
- [application](/{{framework}}/plugins/gatsby/generators/application) - Create a Gatsby application
- [component](/{{framework}}/plugins/gatsby/generators/component) - Create a Gatsby component
- [page](/{{framework}}/plugins/gatsby/generators/page) - Create a Gatsby page