vite.config.ts 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. import { fileURLToPath, URL } from 'node:url'
  2. import tailwindcss from '@tailwindcss/vite'
  3. import vue from '@vitejs/plugin-vue'
  4. import vueJsx from '@vitejs/plugin-vue-jsx'
  5. import { defineConfig } from 'vite'
  6. // import vueDevTools from 'vite-plugin-vue-devtools'
  7. // https://vite.dev/config/
  8. export default defineConfig((env) => {
  9. return {
  10. plugins: [vue(), vueJsx(), tailwindcss()],
  11. resolve: {
  12. alias: {
  13. '@': fileURLToPath(new URL('./src', import.meta.url)),
  14. },
  15. },
  16. server: {
  17. port: 5799,
  18. host: true,
  19. },
  20. build: {
  21. rollupOptions: {
  22. output: {
  23. advancedChunks: {
  24. groups: [
  25. {
  26. name: 'echarts',
  27. test: /\/echarts/,
  28. },
  29. {
  30. name: 'chroma-js',
  31. test: /\/chroma-js/,
  32. },
  33. {
  34. name: 'lodash-es',
  35. test: /\/lodash-es/,
  36. },
  37. {
  38. name: 'naive-ui',
  39. test: /\/naive-ui/,
  40. },
  41. {
  42. name: 'vue-draggable-plus',
  43. test: /\/vue-draggable-plus/,
  44. },
  45. {
  46. name: 'vueuse',
  47. test: /\/vueuse/,
  48. },
  49. {
  50. name: 'vue',
  51. test: /\/vue/,
  52. },
  53. {
  54. name: 'vue-router',
  55. test: /\/vue-router/,
  56. },
  57. {
  58. name: 'pinia',
  59. test: /\/pinia/,
  60. },
  61. ],
  62. },
  63. assetFileNames: (info) => {
  64. const notHash = ['topography.svg', 'texture.png', 'noise.png']
  65. if (notHash.includes(info.names[0])) {
  66. return 'assets/[name][extname]'
  67. }
  68. return 'assets/[name]-[hash][extname]'
  69. },
  70. },
  71. },
  72. },
  73. esbuild: {
  74. drop: env.mode === 'production' ? ['console', 'debugger'] : [],
  75. },
  76. }
  77. })