1.7.0 • Published 10 months ago

@qc2168/vite-plugin-utools v1.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 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
      }
    }
  }
}

HMR Inject

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

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

Options Type

import type { InlineConfig } from 'vite'

export enum BuildMode { IncludeDependencies, ExcludeDependencies }

export interface BuildFileType {
  entry: string | string[]
  vite?: InlineConfig
  mode?: BuildMode
}

export interface BuildJsonType {
  outdir?: string
  entry: string
  address: string
}

export interface OptionsType {
  entry: BuildFileType | BuildFileType[]
  hmr?: boolean | { pluginJsonPath?: string }
}

Example

utools-plugin-template

1.6.2

10 months ago

1.7.0

10 months ago

1.6.1

11 months ago

1.6.0

11 months ago

1.5.1

1 year ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago