vite.config.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import UnoCSS from 'unocss/vite'
  4. import { resolve } from 'path'
  5. // https://vitejs.dev/config/
  6. export default defineConfig({
  7. css: {
  8. extract: true,
  9. },
  10. resolve: {
  11. alias: {
  12. '~src': `${resolve(__dirname, './src')}`
  13. },
  14. },
  15. plugins: [
  16. vue(),
  17. UnoCSS(),
  18. ],
  19. build: {
  20. sourcemap: false,
  21. rollupOptions: {
  22. output: {
  23. manualChunks(id) {
  24. let libStr = '@vue,element-plus,vue-router,js-fast-way'
  25. const libs = libStr.split(',')
  26. if (id.includes('node_modules')) {
  27. const arr = id.toString().split('node_modules/')[1].split('/')
  28. if (libs.indexOf(arr[0]) !== -1) {
  29. return '_' + arr[0]
  30. } else {
  31. return '__vendor'
  32. }
  33. }
  34. },
  35. chunkFileNames: 'static/js1/[name]-[hash].js',
  36. entryFileNames: 'static/js2/[name]-[hash].js',
  37. assetFileNames: 'static/[ext]/[name]-[hash].[ext]',
  38. },
  39. },
  40. brotliSize: false, // 不统计
  41. target: 'esnext',
  42. },
  43. server: {
  44. proxy: {
  45. '/api': {
  46. ws: true,
  47. changeOrigin: true,
  48. //target: "http://39.108.216.210:8090",
  49. target: "http://127.0.0.1:8090",
  50. rewrite: (path) => path.replace(new RegExp('^/api'), '/'),
  51. },
  52. },
  53. },
  54. })