Skip to content

Commit eab6977

Browse files
committed
feat: sqlite3, serialport use-cases
1 parent 0ba40c4 commit eab6977

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

packages/renderer/vite.config.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { defineConfig } from 'vite'
22
import vue from '@vitejs/plugin-vue'
3-
import resolve from 'vite-plugin-resolve'
3+
import resolve, { lib2esm } from 'vite-plugin-resolve'
44
import electron from 'vite-plugin-electron/renderer'
55
import 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
],

0 commit comments

Comments
 (0)