8000 GitHub - ikomom/vite-plugin-utools: High-performance build tools based on vite
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ikomom/vite-plugin-utools

 
 

Repository files navigation

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

About

High-performance build tools based on vite

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 97.8%
  • JavaScript 2.2%
0