File tree Expand file tree Collapse file tree 1 file changed +26
-3
lines changed
Expand file tree Collapse file tree 1 file changed +26
-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,31 @@ 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+ // Equivalent to
28+ /**
29+ * sqlite3: () => `
30+ * const _M_ = require('sqlite3');
31+ * const _D_ = _M_.default || _M_;
32+ * export { _D_ as default }
33+ * `
34+ */
35+ sqlite3 : lib2esm ( 'sqlite3' , { format : 'cjs' } ) ,
36+ serialport : lib2esm (
37+ // CJS lib name
38+ 'serialport' ,
39+ // export memebers
40+ [
41+ 'SerialPort' ,
42+ 'SerialPortMock' ,
43+ ] ,
44+ { format : 'cjs' } ,
45+ ) ,
2346 }
2447 ) ,
2548 ] ,
You can’t perform that action at this time.
0 commit comments