File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed
Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff line change 11import { defineConfig } from 'vite'
22import vue from '@vitejs/plugin-vue'
3- import resolve from 'vite-plugin-resolve'
3+ import resolve , { lib2esm } from 'vite-plugin-resolve'
44import electron from 'vite-plugin-electron/renderer'
55import pkg from '../../package.json'
66
@@ -18,8 +18,23 @@ export default defineConfig({
1818 * which will ensure that the electron-builder can package it correctly
1919 */
2020 {
21- // If you use electron-store, this will work - ESM format code snippets
22- 'electron-store' : 'const Store = require("electron-store"); export default Store;' ,
21+ // If you use the following modules, the following configuration will work
22+ // What they have in common is that they will return - ESM format code snippets
23+
24+ // ESM format string
25+ 'electron-store' : 'export default require("electron-store");' ,
26+ // Use lib2esm() to easy to convert ESM
27+ sqlite3 : lib2esm ( 'sqlite3' , { format : 'cjs' } ) ,
28+ serialport : lib2esm (
29+ // CJS lib name
30+ 'serialport' ,
31+ // export memebers
32+ [
33+ 'SerialPort' ,
34+ 'SerialPortMock' ,
35+ ] ,
36+ { format : 'cjs' } ,
37+ ) ,
2338 }
2439 ) ,
2540 ] ,
You can’t perform that action at this time.
0 commit comments