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({
|
2024-09-19 11:40:10 +08:00
|
|
|
languageWorkers: ['editorWorkerService', 'typescript', 'css'],
|
2024-08-19 20:20:19 +08:00
|
|
|
customDistPath: (_, out) => `${out}/monacoeditorwork`,
|
2024-08-10 17:49:25 +08:00
|
|
|
customWorkers: [
|
|
|
|
{
|
|
|
|
label: 'yaml',
|
|
|
|
entry: 'monaco-yaml/yaml.worker'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
})
|
|
|
|
]
|
2024-07-30 11:04:18 +08:00
|
|
|
}
|
|
|
|
})
|