mirror of
https://github.com/electron-vite/electron-vite-vue
synced 2025-01-31 20:16:36 +08:00
Merge pull request #132 from electron-vite/dev
feat: sqlite3, serialport use-cases
This commit is contained in:
commit
5e0cf0bd4a
@ -1,6 +1,6 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import resolve from 'vite-plugin-resolve'
|
||||
import resolve, { lib2esm } from 'vite-plugin-resolve'
|
||||
import electron from 'vite-plugin-electron/renderer'
|
||||
import pkg from '../../package.json'
|
||||
|
||||
@ -18,8 +18,31 @@ export default defineConfig({
|
||||
* which will ensure that the electron-builder can package it correctly
|
||||
*/
|
||||
{
|
||||
// If you use electron-store, this will work - ESM format code snippets
|
||||
'electron-store': 'const Store = require("electron-store"); export default Store;',
|
||||
// If you use the following modules, the following configuration will work
|
||||
// What they have in common is that they will return - ESM format code snippets
|
||||
|
||||
// ESM format string
|
||||
'electron-store': 'export default require("electron-store");',
|
||||
// Use lib2esm() to easy to convert ESM
|
||||
// Equivalent to
|
||||
/**
|
||||
* sqlite3: () => `
|
||||
* const _M_ = require('sqlite3');
|
||||
* const _D_ = _M_.default || _M_;
|
||||
* export { _D_ as default }
|
||||
* `
|
||||
*/
|
||||
sqlite3: lib2esm('sqlite3', { format: 'cjs' }),
|
||||
serialport: lib2esm(
|
||||
// CJS lib name
|
||||
'serialport',
|
||||
// export memebers
|
||||
[
|
||||
'SerialPort',
|
||||
'SerialPortMock',
|
||||
],
|
||||
{ format: 'cjs' },
|
||||
),
|
||||
}
|
||||
),
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user