nocobase/docs/en-US/development/plugin-ds.md
jack zhang 9e5e96b9e4
fix: improve build (#2643)
* fix: client lib require wrapper

* fix: bug

* fix: add tsconfig.paths.json

* fix: collection dir not exists

* fix: improve...

* fix: update yarn.lock

* fix: db.sync

* fix: bugs

* fix: bugs

* fix: bugs

* fix: bugs && allow user custom build config

* docs: user custom config docs

* refactor: custom user build config

* fix: bugs

* fix: build plugin-client bug

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
2023-09-15 08:51:20 +08:00

1.5 KiB

Plugin directory structure

An empty plugin can be created quickly with yarn pm create my-plugin, with the following directory structure.

|- /my-plugin
  |- /src
    |- /client # client-side of the plugin
    |- /server # server-side of the plugin
  |- client.d.ts
  |- client.js
  |- package.json # plugin package information
  |- server.d.ts
  |- server.js
  |- build.config.ts # or `build.config.js`, modify configuration

The tutorial for /src/server refers to the server section, and the tutorial for /src/client refers to the client section.

If you want to customize the packaging configuration, you can create a config.js file in the root directory, with the following content:

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
  };
})