better resolveElectron comment

This commit is contained in:
草鞋没号 2022-01-21 10:14:56 +08:00
parent f1ae1ad2a1
commit 8f73119ebb

View File

@ -11,7 +11,16 @@ export default defineConfig({
root: join(__dirname, '../src/renderer'), root: join(__dirname, '../src/renderer'),
plugins: [ plugins: [
vue(), 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: './', base: './',
build: { build: {
@ -26,7 +35,7 @@ export default defineConfig({
// ------- For use Electron, NodeJs in Renderer-process ------- // ------- For use Electron, NodeJs in Renderer-process -------
// https://github.com/caoxiemeihao/electron-vue-vite/issues/52 // https://github.com/caoxiemeihao/electron-vue-vite/issues/52
export function resolveElectron(): Plugin[] { export function resolveElectron(dict: Parameters<typeof resolve>[0] = {}): Plugin[] {
const builtins = builtinModules.filter(t => !t.startsWith('_')) const builtins = builtinModules.filter(t => !t.startsWith('_'))
return [ return [
@ -43,8 +52,7 @@ export function resolveElectron(): Plugin[] {
resolve({ resolve({
electron: electronExport(), electron: electronExport(),
...builtinModulesExport(builtins), ...builtinModulesExport(builtins),
// you can custom other module in here, need to make sure it's in `dependencies` ...dict,
// 'electron-store': 'const Store = require("electron-store"); export defalut Store;'
}) })
] ]