escrcpy/vite.config.js

72 lines
1.6 KiB
JavaScript
Raw Normal View History

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