This mono repository is designed to be easily extendable with new plugins for Sanity.
- Create a folder at the top level place (like studio, qrcode etc).
- Add the folder to workspaces array of the top-level package.json.
- Initialise the plugin structure however you prefer.
There are two ways to write a plugin.
- Follow the official instruction.
- Write everything from scratch.
While Sanity recommends the first variant, we may prefer the second one. The reason is that the official bootstrapped structure is way too heavy and event cannot work properly (a conflict in dependencies, mental overhead, etc.). The manual variant requires writing a minimum amount of configuration and code to get the job done. An example of manually crafted plugin is qrcode.
- Run
npm i
to add the new plugin to top-level node_modules, so it can be included to other local repositories (we need it for testing). - Write the code.
- If you want to show what the plugin looks like visually, make an image(s) somehow and put it to the assets directory. After that, you can refer to those images from the README.
- Stay sane.
Check if plugin is working the way it needs to work in the Sanity Studio. For that reason, the testing studio lives in the studio repository.
If you know how to write automated tests for plugins, please leave your knowledge here and write tests at least to one plugin, so we will know as well.
-
Create the
.env.local
file in the studio folder with the following content:SANITY_STUDIO_PROJECT_ID=47oc2r8x SANITY_STUDIO_DATASET_TYPE=production
-
Add the plugin as a dependency to Studio's
package.json
(You can refer to it the same way as you include packages from npm). -
Include plugin to the
plugins
array of the Studio'ssanity.config.ts
file. -
Optional: you may need to run
npm i
. -
Ask Sergey Diniovskiy or Ihor Bozhuk to invite you to the Studio, so you can log in.
-
Test like crazy.
Have fun ✌️