escrcpy/vite.config.js

73 lines
1.7 KiB
JavaScript
Raw Normal View History

2023-10-15 18:18:24 +02:00
import { resolve } from 'node:path'
2024-09-07 19:55:54 +02:00
import useI18n from '@intlify/unplugin-vue-i18n/vite'
import useVue from '@vitejs/plugin-vue'
import useUnoCSS from 'unocss/vite'
import { defineConfig, mergeConfig } from 'vite'
2024-09-07 19:55:54 +02:00
import { notBundle } from 'vite-plugin-electron/plugin'
import useElectron from 'vite-plugin-electron/simple'
2023-10-15 18:18:24 +02:00
import useRenderer from 'vite-plugin-electron-renderer'
import useSvg from 'vite-svg-loader'
import postcssConfig from './postcss.config.js'
import useAutoImports from './src/plugins/auto.js'
2023-11-13 11:35:44 +01:00
2024-09-12 13:11:46 +02:00
const alias = {
$: resolve('src'),
$root: resolve(),
$renderer: resolve('src'),
$electron: resolve('electron'),
$control: resolve('control'),
}
function mergeCommon(config, { command = '' } = {}) {
return mergeConfig(
{
resolve: {
2024-09-12 13:11:46 +02:00
alias,
},
plugins: [...(command === 'serve' ? [notBundle()] : [])],
},
config,
)
2024-09-12 13:11:46 +02:00
}
2023-10-15 18:18:24 +02:00
2024-09-12 13:11:46 +02:00
export default function (args) {
return mergeCommon(
defineConfig({
2023-11-17 11:42:50 +01:00
build: {
rollupOptions: {
input: {
main: resolve('index.html'),
2024-09-12 13:11:46 +02:00
control: resolve('control/index.html'),
2023-11-17 11:42:50 +01: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',
2024-09-12 13:11:46 +02:00
vite: mergeCommon({}, args),
},
preload: {
input: 'electron/preload.js',
2024-09-12 13:11:46 +02:00
vite: mergeCommon({}, args),
},
}),
useRenderer(),
...useAutoImports(),
],
2023-11-13 11:35:44 +01:00
css: {
postcss: postcssConfig,
},
}),
)
2024-09-12 13:11:46 +02:00
}