0
Fork 0
mirror of https://github.com/penpot/penpot-plugins.git synced 2025-01-09 00:10:12 -05:00
penpot-plugins/docs/create-plugin.md

56 lines
1.2 KiB
Markdown
Raw Normal View History

2024-03-12 01:48:02 -05:00
# Create plugin
To create the basic scaffolding run the following command. Remember to replace `example-plugin` with your own.
```
2024-02-06 06:16:28 -05:00
npx nx g @nx/web:application example-plugin --directory=apps/example-plugin
2024-03-12 01:48:02 -05:00
```
2024-02-06 06:16:28 -05:00
2024-03-25 06:43:55 -05:00
Create a `manifest.json` in `/public`.
2024-02-06 06:16:28 -05:00
```json
{
"name": "Example plugin",
2024-03-04 04:49:53 -05:00
"code": "http://localhost:4201/plugin.js",
"permissions": ["page:read", "file:read", "selection:read"]
2024-02-06 06:16:28 -05:00
}
```
2024-02-27 08:50:38 -05:00
Add to the example `vite.config.ts`
2024-02-06 06:16:28 -05:00
```json
build: {
rollupOptions: {
input: {
plugin: 'src/plugin.ts',
index: './index.html',
},
output: {
entryFileNames: '[name].js',
},
},
}
```
2024-02-27 08:50:38 -05:00
Add to `tsconfig.app.json`
```json
"include": ["src/**/*.ts", "../../libs/plugins-runtime/src/lib/index.d.ts"]
```
2024-03-12 01:48:02 -05:00
Then, run the static server
2024-02-06 06:16:28 -05:00
2024-03-12 01:48:02 -05:00
```
npx nx run example-plugin:build --watch & npx nx run example-plugin:preview
2024-03-12 01:48:02 -05:00
```
Finally, go to penpot and load the plugin. Run the command in the console devtools from your browser.
2024-02-06 06:16:28 -05:00
```ts
ɵloadPlugin({ manifest: 'http://localhost:4201/manifest.json' });
```
2024-03-12 01:48:02 -05:00
### More about plugin development
Check the [plugin usage](docs/plugin-usage.md) and the [create API](docs/create-api.md) documentation.