Easier to develop utools plugin
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
}
}
}
}
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'}
})
]
You can using auto inject development.main
, to achieve hot updates
utools({
hmr: {
pluginJsonPath: 'your plugin.json path'
}})
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;
};
}