mihomo-party/electron.vite.config.ts

45 lines
1.2 KiB
TypeScript
Raw Normal View History

2024-07-30 11:04:18 +08:00
import { resolve } from 'path'
import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
import react from '@vitejs/plugin-react'
2024-08-10 17:49:25 +08:00
// https://github.com/vdesjs/vite-plugin-monaco-editor/issues/21#issuecomment-1827562674
import monacoEditorPluginModule from 'vite-plugin-monaco-editor'
const isObjectWithDefaultFunction = (
module: unknown
): module is { default: typeof monacoEditorPluginModule } =>
module != null &&
typeof module === 'object' &&
'default' in module &&
typeof module.default === 'function'
const monacoEditorPlugin = isObjectWithDefaultFunction(monacoEditorPluginModule)
? monacoEditorPluginModule.default
: monacoEditorPluginModule
2024-07-30 11:04:18 +08:00
export default defineConfig({
main: {
plugins: [externalizeDepsPlugin()]
},
preload: {
plugins: [externalizeDepsPlugin()]
},
renderer: {
resolve: {
alias: {
'@renderer': resolve('src/renderer/src')
}
},
2024-08-10 17:49:25 +08:00
plugins: [
react(),
monacoEditorPlugin({
languageWorkers: ['editorWorkerService', 'typescript', 'json'],
customDistPath: () => 'out/renderer',
customWorkers: [
{
label: 'yaml',
entry: 'monaco-yaml/yaml.worker'
}
]
})
]
2024-07-30 11:04:18 +08:00
}
})