vite.config.ts 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { fileURLToPath } from 'url'
  2. import { defineConfig } from 'vite'
  3. import electronPlugin from 'vite-plugin-electron'
  4. import rendererPlugin from 'vite-plugin-electron-renderer'
  5. import eslintPlugin from 'vite-plugin-eslint'
  6. import vuetifyPlugin from 'vite-plugin-vuetify'
  7. import vueJsx from '@vitejs/plugin-vue-jsx'
  8. import vue from '@vitejs/plugin-vue'
  9. import { rmSync } from 'fs'
  10. import { resolve, dirname } from 'path'
  11. import { builtinModules } from 'module'
  12. export default defineConfig(() => {
  13. rmSync('dist', { recursive: true, force: true })
  14. return {
  15. define: {
  16. __VUE_I18N_FULL_INSTALL__: true,
  17. __VUE_I18N_LEGACY_API__: false,
  18. __INTLIFY_PROD_DEVTOOLS__: false
  19. },
  20. resolve: {
  21. extensions: ['.mjs', '.js', '.ts', '.vue', '.json', '.scss'],
  22. alias: {
  23. '@': resolve(dirname(fileURLToPath(import.meta.url)), 'src')
  24. }
  25. },
  26. base: './',
  27. root: resolve('./src/renderer'),
  28. publicDir: resolve('./src/renderer/public'),
  29. clearScreen: false,
  30. build: {
  31. assetsDir: '', // See: https://github.com/electron-vite/electron-vite-vue/issues/287
  32. outDir: resolve('./dist')
  33. },
  34. plugins: [
  35. vue(),
  36. vueJsx(),
  37. // Docs: https://github.com/vuetifyjs/vuetify-loader
  38. vuetifyPlugin({
  39. autoImport: true
  40. }),
  41. // Docs: https://github.com/gxmari007/vite-plugin-eslint
  42. eslintPlugin(),
  43. // Docs: https://github.com/electron-vite/vite-plugin-electron
  44. electronPlugin([
  45. {
  46. entry: ['src/main/index.ts'],
  47. onstart: (options) => {
  48. options.startup()
  49. },
  50. vite: {
  51. build: {
  52. assetsDir: '.',
  53. outDir: 'dist/main',
  54. rollupOptions: {
  55. external: ['electron', ...builtinModules]
  56. }
  57. }
  58. }
  59. },
  60. {
  61. entry: ['src/preload/index.ts'],
  62. onstart: (options) => {
  63. options.reload()
  64. },
  65. vite: {
  66. build: {
  67. outDir: 'dist/preload'
  68. }
  69. }
  70. }
  71. ]),
  72. rendererPlugin()
  73. ]
  74. }
  75. })