vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import eslint from 'vite-plugin-eslint'
  4. import { resolve } from 'path'
  5. import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
  6. import electron from 'vite-plugin-electron'
  7. export default () => defineConfig({
  8. base: './',
  9. resolve: {
  10. alias: {
  11. '@': resolve(__dirname, './src')
  12. }
  13. },
  14. plugins: [
  15. vue(),
  16. eslint({ fix: true, include: ['**/*.ts', '**/*.vue'] }),
  17. createSvgIconsPlugin({
  18. iconDirs: [resolve(__dirname, './src/assets/icons')],
  19. // Specify symbolId format
  20. symbolId: 'icon-[dir]-[name]'
  21. }),
  22. electron({
  23. entry: 'electron/main.js'
  24. }),
  25. ],
  26. server: {
  27. host: '0.0.0.0',
  28. port: 6547,
  29. open: false,
  30. strictPort: false,
  31. https: false,
  32. },
  33. // esbuild: {
  34. // drop: ['console', 'debugger'] // build 移除打印
  35. // },
  36. build: {
  37. rollupOptions: {
  38. input: {
  39. index: resolve(__dirname, 'index.html')
  40. },
  41. output: { // 静态资源分类打包
  42. chunkFileNames: 'js/[hash].js',
  43. entryFileNames: 'js/[hash].js',
  44. assetFileNames: 'assets/[ext]/[hash].[ext]',
  45. // 拆分node_modules包
  46. manualChunks: (id) => {
  47. if (id.includes('node_modules')) {
  48. return id.toString().split('node_modules/')[1].split('/')[0].toString()
  49. }
  50. return ''
  51. }
  52. }
  53. },
  54. outDir:'dist/electron/'
  55. },
  56. define: {
  57. __VUE_OPTIONS_API__: false
  58. }
  59. })