2022-11-06 08:43:40 +08:00
|
|
|
# Plugin directory structure
|
2022-10-31 22:41:24 +08:00
|
|
|
|
2022-11-06 08:43:40 +08:00
|
|
|
An empty plugin can be created quickly with `yarn pm create my-plugin`, with the following directory structure.
|
2022-10-31 22:41:24 +08:00
|
|
|
|
|
|
|
```bash
|
|
|
|
|- /my-plugin
|
|
|
|
|- /src
|
2022-11-06 08:43:40 +08:00
|
|
|
|- /client # client-side of the plugin
|
|
|
|
|- /server # server-side of the plugin
|
2022-10-31 22:41:24 +08:00
|
|
|
|- client.d.ts
|
|
|
|
|- client.js
|
2022-11-06 08:43:40 +08:00
|
|
|
|- package.json # plugin package information
|
2022-10-31 22:41:24 +08:00
|
|
|
|- server.d.ts
|
|
|
|
|- server.js
|
2023-09-15 08:51:20 +08:00
|
|
|
|- build.config.ts # or `build.config.js`, modify configuration
|
2022-10-31 22:41:24 +08:00
|
|
|
```
|
|
|
|
|
2022-11-06 08:43:40 +08:00
|
|
|
The tutorial for `/src/server` refers to the [server](./server) section, and the tutorial for `/src/client` refers to the [client](./client) section.
|
2023-09-15 08:51:20 +08:00
|
|
|
|
|
|
|
If you want to customize the packaging configuration, you can create a `config.js` file in the root directory, with the following content:
|
|
|
|
|
|
|
|
```js
|
|
|
|
import { defineConfig } from '@nocobase/build';
|
|
|
|
|
|
|
|
export default defineConfig({
|
|
|
|
modifyViteConfig: (config) => {
|
|
|
|
// vite is used to package the `src/client` side code
|
|
|
|
|
|
|
|
// Modify the Vite configuration, for more information, please refer to: https://vitejs.dev/guide/
|
|
|
|
return config
|
|
|
|
},
|
|
|
|
modifyTsupConfig: (config) => {
|
|
|
|
// tsup is used to package the `src/server` side code
|
|
|
|
|
|
|
|
// Modify the tsup configuration, for more information, please refer to: https://tsup.egoist.dev/#using-custom-configuration
|
|
|
|
return config
|
|
|
|
},
|
|
|
|
beforeBuild: (log) => {
|
|
|
|
// The callback function before the build starts, you can do some operations before the build starts
|
|
|
|
},
|
|
|
|
afterBuild: (log: PkgLog) => {
|
|
|
|
// The callback function after the build is completed, you can do some operations after the build is completed
|
|
|
|
};
|
|
|
|
})
|
|
|
|
```
|