2023-10-16 00:18:24 +08:00
|
|
|
import { resolve } from 'node:path'
|
2023-10-16 11:53:08 +08:00
|
|
|
import { defineConfig, mergeConfig } from 'vite'
|
2023-10-16 00:18:24 +08:00
|
|
|
import useElectron from 'vite-plugin-electron'
|
|
|
|
import useRenderer from 'vite-plugin-electron-renderer'
|
2023-10-17 18:16:37 +08:00
|
|
|
import { notBundle } from 'vite-plugin-electron/plugin'
|
2023-10-16 00:18:24 +08:00
|
|
|
|
|
|
|
import useVue from '@vitejs/plugin-vue'
|
|
|
|
import useEslint from 'vite-plugin-eslint'
|
|
|
|
import useUnoCSS from 'unocss/vite'
|
2023-10-17 17:54:29 +08:00
|
|
|
import useSvg from 'vite-svg-loader'
|
2023-10-23 18:14:41 +08:00
|
|
|
import useI18n from '@intlify/unplugin-vue-i18n/vite'
|
2023-10-16 11:53:08 +08:00
|
|
|
|
2023-11-13 18:35:44 +08:00
|
|
|
import postcssConfig from './postcss.config.mjs'
|
|
|
|
|
2023-10-17 18:16:37 +08:00
|
|
|
const merge = (config, { command = '' } = {}) =>
|
2023-10-16 11:53:08 +08:00
|
|
|
mergeConfig(
|
|
|
|
{
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2023-10-17 15:27:08 +08:00
|
|
|
'@root': resolve(),
|
|
|
|
'@electron': resolve('electron'),
|
2023-11-07 14:09:09 +08:00
|
|
|
'@renderer': resolve('src'),
|
2023-10-16 11:53:08 +08:00
|
|
|
},
|
|
|
|
},
|
2023-10-17 18:16:37 +08:00
|
|
|
plugins: [...(command === 'serve' ? [notBundle()] : [])],
|
2023-10-16 11:53:08 +08:00
|
|
|
},
|
|
|
|
config,
|
|
|
|
)
|
2023-10-16 00:18:24 +08:00
|
|
|
|
|
|
|
// https://vitejs.dev/config/
|
2023-10-17 18:16:37 +08:00
|
|
|
export default params =>
|
|
|
|
merge(
|
|
|
|
defineConfig({
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
|
|
|
'@': resolve('src'),
|
2023-10-24 11:08:27 +08:00
|
|
|
'@electron': resolve('electron'),
|
2023-10-16 00:18:24 +08:00
|
|
|
},
|
2023-10-17 18:16:37 +08:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
useEslint(),
|
|
|
|
useUnoCSS(),
|
|
|
|
useSvg(),
|
|
|
|
useVue(),
|
2023-10-23 18:14:41 +08:00
|
|
|
useI18n({
|
2023-10-24 20:55:12 +08:00
|
|
|
include: [resolve(__dirname, './src/locales/languages/**')],
|
2023-10-23 18:14:41 +08:00
|
|
|
}),
|
2023-10-17 18:16:37 +08:00
|
|
|
useElectron([
|
|
|
|
{
|
|
|
|
entry: 'electron/main.js',
|
|
|
|
vite: merge({}, params),
|
2023-10-17 15:27:08 +08:00
|
|
|
},
|
2023-10-17 18:16:37 +08:00
|
|
|
{
|
|
|
|
entry: 'electron/preload.js',
|
|
|
|
onstart(args) {
|
|
|
|
args.reload()
|
|
|
|
},
|
|
|
|
vite: merge({}, params),
|
|
|
|
},
|
|
|
|
]),
|
|
|
|
useRenderer(),
|
|
|
|
],
|
2023-11-13 18:35:44 +08:00
|
|
|
css: {
|
|
|
|
postcss: postcssConfig,
|
|
|
|
},
|
2023-10-17 18:16:37 +08:00
|
|
|
}),
|
|
|
|
)
|