escrcpy/vite.config.js

74 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-10-15 18:18:24 +02:00
import { resolve } from 'node:path'
import { defineConfig, mergeConfig } from 'vite'
import useElectron from 'vite-plugin-electron/simple'
2023-10-15 18:18:24 +02:00
import useRenderer from 'vite-plugin-electron-renderer'
import { notBundle } from 'vite-plugin-electron/plugin'
2023-10-15 18:18:24 +02:00
import useVue from '@vitejs/plugin-vue'
import useUnoCSS from 'unocss/vite'
import useSvg from 'vite-svg-loader'
2023-10-23 12:14:41 +02:00
import useI18n from '@intlify/unplugin-vue-i18n/vite'
import postcssConfig from './postcss.config.js'
import useAutoImports from './src/plugins/auto.js'
2023-11-13 11:35:44 +01:00
const merge = (config, { command = '' } = {}) =>
mergeConfig(
{
resolve: {
alias: {
2024-05-15 05:16:02 +02:00
$root: resolve(),
$electron: resolve('electron'),
$renderer: resolve('src'),
},
},
plugins: [...(command === 'serve' ? [notBundle()] : [])],
},
config,
)
2023-10-15 18:18:24 +02:00
export default args =>
merge(
defineConfig({
2023-11-17 11:42:50 +01:00
build: {
rollupOptions: {
input: {
main: resolve('index.html'),
copilot: resolve('copilot/index.html'),
2023-11-17 11:42:50 +01:00
},
},
},
resolve: {
alias: {
2024-05-15 05:16:02 +02:00
$: resolve('src'),
$copilot: resolve('copilot'),
$electron: resolve('electron'),
2023-10-15 18:18:24 +02:00
},
},
plugins: [
useUnoCSS(),
useSvg(),
useVue(),
2023-10-23 12:14:41 +02:00
useI18n({
include: [resolve('src/locales/languages/**')],
2023-10-23 12:14:41 +02:00
}),
useElectron({
main: {
entry: 'electron/main.js',
vite: merge({}, args),
},
preload: {
input: 'electron/preload.js',
vite: merge({}, args),
},
}),
useRenderer(),
...useAutoImports(),
],
2023-11-13 11:35:44 +01:00
css: {
postcss: postcssConfig,
},
}),
)