You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Building your own [Payload Plugin](./overview) is easy, and if you're already familiar with Payload then you'll have everything you need to get started. You can either start from scratch or use the [Plugin Template](#plugin-template) to get up and running quickly.
9
+
Building your own [Payload Plugin](./overview) is easy, and if you're already familiar with Payload then you'll have everything you need to get started. You can either start from scratch or use the [Plugin Template](#plugin-template) to get up and running quickly.
10
10
11
11
<Bannertype="success">
12
12
To use the template, run `npx create-payload-app@latest --template plugin` directly in
@@ -19,7 +19,7 @@ Our plugin template includes everything you need to build a full life-cycle plug
19
19
- A local dev environment to develop the plugin
20
20
- Test suite with integrated GitHub workflow
21
21
22
-
By abstracting your code into a plugin, you'll be able to reuse your feature across multiple projects and make it available for other developers to use.
22
+
By abstracting your code into a plugin, you'll be able to reuse your feature across multiple projects and make it available for other developers to use.
23
23
24
24
## Plugins Recap
25
25
@@ -75,15 +75,15 @@ The purpose of the **dev** folder is to provide a sanitized local Payload projec
75
75
76
76
Do **not** store any of the plugin functionality in this folder - it is purely an environment to _assist_ you with developing the plugin.
77
77
78
-
If you're starting from scratch, you can easily setup a dev environment like this:
78
+
If you're starting from scratch, you can easily setup a dev environment like this:
79
79
80
80
```
81
81
mkdir dev
82
82
cd dev
83
83
npx create-payload-app@latest
84
84
```
85
85
86
-
If you're using the plugin template, the dev folder is built out for you and the `samplePlugin` has already been installed in `dev/payload.config.ts`.
86
+
If you're using the plugin template, the dev folder is built out for you and the `samplePlugin` has already been installed in `dev/payload.config.ts`.
87
87
88
88
```
89
89
plugins: [
@@ -96,7 +96,7 @@ If you're using the plugin template, the dev folder is built out for you an
96
96
97
97
You can add to the `dev/payload.config.ts` and build out the dev project as needed to test your plugin.
98
98
99
-
When you're ready to start development, navigate into this folder with `cd dev`
99
+
When you're ready to start development, navigate into this folder with `cd dev`
100
100
101
101
And then start the project with `pnpm dev` and pull up `http://localhost:3000` in your browser.
102
102
@@ -108,7 +108,7 @@ A good test suite is essential to ensure quality and stability in your plugin. P
108
108
109
109
Jest organizes tests into test suites and cases. We recommend creating tests based on the expected behavior of your plugin from start to finish. Read more about tests in the [Jest documentation.](https://jestjs.io/)
110
110
111
-
The plugin template provides a stubbed out test suite at `dev/plugin.spec.ts` which is ready to go - just add in your own test conditions and you're all set!
111
+
The plugin template provides a stubbed out test suite at `dev/plugin.spec.ts` which is ready to go - just add in your own test conditions and you're all set!
Now that we have our environment setup and dev project ready to go - it's time to build the plugin!
163
+
Now that we have our environment setup and dev project ready to go - it's time to build the plugin!
164
164
165
165
166
166
```
@@ -217,7 +217,7 @@ To reiterate, the essence of a [Payload Plugin](./overview) is simply to extend
217
217
218
218
We are going to use spread syntax to allow us to add data to existing arrays without losing the existing data. It is crucial to spread the existing data correctly, else this can cause adverse behavior and conflicts with Payload Config and other plugins.
219
219
220
-
Let's say you want to build a plugin that adds a new collection:
220
+
Let's say you want to build a plugin that adds a new collection:
221
221
222
222
```
223
223
config.collections = [
@@ -227,7 +227,7 @@ config.collections = [
227
227
]
228
228
```
229
229
230
-
First, you need to spread the `config.collections` to ensure that we don't lose the existing collections. Then you can add any additional collections, just as you would in a regular Payload Config.
230
+
First, you need to spread the `config.collections` to ensure that we don't lose the existing collections. Then you can add any additional collections, just as you would in a regular Payload Config.
231
231
232
232
This same logic is applied to other array and object like properties such as admin, globals and hooks:
233
233
@@ -284,7 +284,7 @@ For a better user experience, provide a way to disable the plugin without uninst
284
284
285
285
### Include tests in your GitHub CI workflow
286
286
287
-
If you've configured tests for your package, integrate them into your workflow to run the tests each time you commit to the plugin repository. Learn more about [how to configure tests into your GitHub CI workflow.](https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-nodejs)
287
+
If you've configured tests for your package, integrate them into your workflow to run the tests each time you commit to the plugin repository. Learn more about [how to configure tests into your GitHub CI workflow.](https://docs.github.com/en/actions/use-cases-and-examples/building-and-testing/building-and-testing-nodejs)
0 commit comments