52 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-03-28 10:57:56 +08:00
import { defineConfig } from 'vite'
2021-11-11 17:52:50 +08:00
import vue from '@vitejs/plugin-vue'
2022-05-17 14:47:37 +08:00
import resolve, { lib2esm } from 'vite-plugin-resolve'
import electron from 'vite-plugin-electron/renderer'
import pkg from '../../package.json'
2021-11-11 17:52:50 +08:00
// https://vitejs.dev/config/
export default defineConfig({
2021-11-27 10:51:32 +08:00
mode: process.env.NODE_ENV,
root: __dirname,
plugins: [
vue(),
2022-03-28 10:57:56 +08:00
electron(),
resolve(
2022-01-21 10:14:56 +08:00
/**
* Here you can specify other modules
* 🚧 You have to make sure that your module is in `dependencies` and not in the` devDependencies`,
* which will ensure that the electron-builder can package it correctly
2022-01-21 10:14:56 +08:00
*/
{
2022-05-17 14:47:37 +08:00
// 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
sqlite3: lib2esm('sqlite3', { format: 'cjs' }),
serialport: lib2esm(
// CJS lib name
'serialport',
// export memebers
[
'SerialPort',
'SerialPortMock',
],
{ format: 'cjs' },
),
2022-03-28 10:57:56 +08:00
}
2022-01-21 10:14:56 +08:00
),
],
2021-11-11 17:52:50 +08:00
base: './',
build: {
outDir: '../../dist/renderer',
2022-04-15 07:52:22 +08:00
emptyOutDir: true,
sourcemap: true,
2021-11-11 17:52:50 +08:00
},
server: {
2022-03-15 08:34:23 +08:00
host: pkg.env.VITE_DEV_SERVER_HOST,
port: pkg.env.VITE_DEV_SERVER_PORT,
2021-11-11 17:52:50 +08:00
},
})