From 8f73119ebba1e3dfdafb0aba5d70a45c0f91151b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8D=89=E9=9E=8B=E6=B2=A1=E5=8F=B7?= <308487730@qq.com> Date: Fri, 21 Jan 2022 10:14:56 +0800 Subject: [PATCH] better resolveElectron comment --- configs/vite-renderer.config.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/configs/vite-renderer.config.ts b/configs/vite-renderer.config.ts index 686c2a7..09e6b58 100644 --- a/configs/vite-renderer.config.ts +++ b/configs/vite-renderer.config.ts @@ -11,7 +11,16 @@ export default defineConfig({ root: join(__dirname, '../src/renderer'), plugins: [ vue(), - resolveElectron(), + resolveElectron( + /** + * you can custom other module in here + * 🚧 need to make sure custom-resolve-module in `dependencies`, that will ensure that the electron-builder can package them correctly + * @example + * { + * 'electron-store': 'const Store = require("electron-store"); export defalut Store;', + * } + */ + ), ], base: './', build: { @@ -26,7 +35,7 @@ export default defineConfig({ // ------- For use Electron, NodeJs in Renderer-process ------- // https://github.com/caoxiemeihao/electron-vue-vite/issues/52 -export function resolveElectron(): Plugin[] { +export function resolveElectron(dict: Parameters[0] = {}): Plugin[] { const builtins = builtinModules.filter(t => !t.startsWith('_')) return [ @@ -43,8 +52,7 @@ export function resolveElectron(): Plugin[] { resolve({ electron: electronExport(), ...builtinModulesExport(builtins), - // you can custom other module in here, need to make sure it's in `dependencies` - // 'electron-store': 'const Store = require("electron-store"); export defalut Store;' + ...dict, }) ]