vite.config.ts 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. },
  19. build: {
  20. rollupOptions: {
  21. output: {
  22. advancedChunks: {
  23. groups: [
  24. {
  25. name: 'echarts',
  26. test: /\/echarts/,
  27. },
  28. {
  29. name: 'chroma-js',
  30. test: /\/chroma-js/,
  31. },
  32. {
  33. name: 'lodash-es',
  34. test: /\/lodash-es/,
  35. },
  36. {
  37. name: 'naive-ui',
  38. test: /\/naive-ui/,
  39. },
  40. {
  41. name: 'vue-draggable-plus',
  42. test: /\/vue-draggable-plus/,
  43. },
  44. {
  45. name: 'vueuse',
  46. test: /\/vueuse/,
  47. },
  48. {
  49. name: 'vue',
  50. test: /\/vue/,
  51. },
  52. {
  53. name: 'vue-router',
  54. test: /\/vue-router/,
  55. },
  56. {
  57. name: 'pinia',
  58. test: /\/pinia/,
  59. },
  60. ],
  61. },
  62. assetFileNames: (info) => {
  63. const notHash = ['topography.svg', 'texture.png', 'noise.png']
  64. if (notHash.includes(info.names[0])) {
  65. return 'assets/[name][extname]'
  66. }
  67. return 'assets/[name]-[hash][extname]'
  68. },
  69. },
  70. },
  71. },
  72. esbuild: {
  73. drop: env.mode === 'production' ? ['console', 'debugger'] : [],
  74. },
  75. }
  76. })