1.5.0 • Published 3 months ago

@qc2168/vite-plugin-utools v1.5.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 months ago

vite-plugin-utools

Easier to develop utools plugin

Usage

Install the plugin

npm i @qc2168/vite-plugin-utools -D

In the vite config file, add the vite-plugin-utools

// vite.config.ts
  plugins: [
    utools({ entry: [
      { entry: 'utools/main.ts' },
      { entry: 'utools/preload.ts' }
    ] })
  ]

Create a main.js file and pass the file path to plugin

// main.js
window.exports = {
    // plugin entrance
    "demo": {
        mode: "none",
        args: {
            enter: async () => {
                // some things
            }
        }
    }
}

Upx Build

By default, upx is not built, if you want to build, you just need to set up the upx object

// vite.config.ts
  plugins: [
    utools({
      entry: ['./utools/main.js'],
      upx: {pluginJsonPath:'your plugin.json path'}
    })
  ]

HMR Inject

You can using auto inject development.main, to achieve hot updates

utools({
  hmr: {
    pluginJsonPath: 'your plugin.json path'
  }})

Options Type

interface UpxBuildType {
    entry?: string;
    pluginJsonPath: string;
    outDir?: string;
    packageName?: string;
}

interface BuildFileType {
    entry: string | string[];
    vite?: InlineConfig;
}

interface OptionsType {
    entry: BuildFileType | BuildFileType[];
    upx?: false | UpxBuildType;
    hmr?: false | {
        pluginJsonPath?: string;
    };
}

Example

utools-plugin-template

1.5.0

3 months ago

1.4.0

4 months ago

1.3.1

5 months ago

1.3.0

6 months ago

1.2.0

6 months ago

1.1.1

6 months ago

1.1.0

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago