1.7.0 • Published 10 months ago
@qc2168/vite-plugin-utools v1.7.0
vite-plugin-utools
Easier to develop utools plugin
Usage
Install the plugin
npm i @qc2168/vite-plugin-utools -DIn 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 }
}