vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. export default () => defineConfig({
  7. base: './',
  8. css: {
  9. preprocessorOptions: {
  10. scss: {
  11. api: 'modern-compiler'
  12. }
  13. }
  14. },
  15. clearScreen: false,
  16. resolve: {
  17. alias: {
  18. '@': resolve(__dirname, './src')
  19. }
  20. },
  21. plugins: [
  22. vue(),
  23. eslint({ fix: true, include: ['**/*.ts', '**/*.vue'] }),
  24. createSvgIconsPlugin({
  25. iconDirs: [resolve(__dirname, './src/assets/icons')],
  26. // Specify symbolId format
  27. symbolId: 'icon-[dir]-[name]'
  28. }),
  29. ],
  30. server: {
  31. host: '0.0.0.0',
  32. port: 6547,
  33. open: false,
  34. strictPort: true,
  35. watch: {
  36. // 3. tell vite to ignore watching `src-tauri`
  37. ignored: ["**/src-tauri/**"],
  38. },
  39. },
  40. build: {
  41. rollupOptions: {
  42. input: {
  43. index: resolve(__dirname, 'index.html')
  44. },
  45. output: { // 静态资源分类打包
  46. chunkFileNames: 'js/[hash].js',
  47. entryFileNames: 'js/[hash].js',
  48. assetFileNames: 'assets/[ext]/[hash].[ext]',
  49. // 拆分node_modules包
  50. manualChunks: (id) => {
  51. if (id.includes('node_modules')) {
  52. return id.toString().split('node_modules/')[1].split('/')[0].toString()
  53. }
  54. return ''
  55. }
  56. }
  57. },
  58. },
  59. define: {
  60. __VUE_OPTIONS_API__: false
  61. }
  62. })