A8000
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.3 KiB

8 months ago
8 months ago
8 months ago
8 months ago
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import path from 'path'
  4. import AutoImport from 'unplugin-auto-import/vite'
  5. import Components from 'unplugin-vue-components/vite'
  6. import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
  7. // https://vitejs.dev/config/
  8. export default defineConfig({
  9. base: './',
  10. plugins: [
  11. vue(),
  12. AutoImport({
  13. resolvers: [ElementPlusResolver()],
  14. }),
  15. Components({
  16. resolvers: [ElementPlusResolver()],
  17. }),
  18. ],
  19. resolve: {
  20. extensions: ['.js', '.ts', '.vue', '.json'], // 添加 .ts 扩展名解析
  21. alias: {
  22. '@': path.resolve(__dirname, 'src'),
  23. },
  24. },
  25. build: {
  26. minify: 'terser',
  27. outDir: 'dist',
  28. assetsDir: 'assets',
  29. rollupOptions: {
  30. output: {
  31. assetFileNames: 'assets/[name].[hash][extname]',
  32. chunkFileNames: 'assets/[name].[hash].js',
  33. entryFileNames: 'assets/[name].[hash].js',
  34. },
  35. },
  36. terserOptions: {
  37. compress: {
  38. drop_console: true,
  39. drop_debugger: true,
  40. },
  41. },
  42. },
  43. preview: {
  44. port: 4173,
  45. strictPort: true,
  46. // 移除之前的 proxy 配置
  47. // 添加正确的静态文件服务配置
  48. cors: true,
  49. headers: {
  50. 'Access-Control-Allow-Origin': '*',
  51. },
  52. },
  53. })