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'
|
2022-04-06 08:35:54 +08:00
|
|
|
import electron from 'vite-plugin-electron/renderer'
|
2022-01-27 08:49:40 +08:00
|
|
|
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,
|
2022-01-27 08:49:40 +08:00
|
|
|
root: __dirname,
|
2022-01-16 09:09:21 +08:00
|
|
|
plugins: [
|
|
|
|
vue(),
|
2022-03-28 10:57:56 +08:00
|
|
|
electron(),
|
|
|
|
resolve(
|
2022-01-21 10:14:56 +08:00
|
|
|
/**
|
2022-02-08 11:14:05 +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-03-13 21:52:58 +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
|
2022-05-17 17:19:58 +08:00
|
|
|
// Equivalent to
|
|
|
|
/**
|
|
|
|
* sqlite3: () => `
|
|
|
|
* const _M_ = require('sqlite3');
|
|
|
|
* const _D_ = _M_.default || _M_;
|
|
|
|
* export { _D_ as default }
|
|
|
|
* `
|
|
|
|
*/
|
2022-05-17 14:47:37 +08:00
|
|
|
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
|
|
|
),
|
2022-01-16 09:09:21 +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
|
|
|
},
|
|
|
|
})
|