vite.config.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import eslint from 'vite-plugin-eslint'
  4. import path from 'path'
  5. // https://vitejs.dev/config/
  6. export default defineConfig({
  7. base: './',
  8. resolve: {
  9. alias: {
  10. /*
  11. 路径别名
  12. 若为文件系统路径必须是绝对路径的形式,否则将以别名原样呈现,不会解析为文件系统路径路径
  13. */
  14. '@': path.resolve(__dirname, './src')
  15. }
  16. },
  17. plugins: [vue(), eslint({ fix: true })],
  18. server: {
  19. host: 'localhost',
  20. port: 6547,
  21. open: true,
  22. strictPort: false,
  23. https: false
  24. // 反向代理
  25. // proxy: {
  26. // '/': {
  27. // target: 'http://172.16.1.215:5000',
  28. // changeOrigin: true,
  29. // rewrite: (path) => path.replace(/^\//, '')
  30. // },
  31. // }
  32. },
  33. build: {
  34. rollupOptions: {
  35. input: {
  36. admin: path.resolve(__dirname, 'admin.html'),
  37. index: path.resolve(__dirname, 'index.html'),
  38. login: path.resolve(__dirname, 'login.html')
  39. },
  40. output: { // 静态资源分类打包
  41. chunkFileNames: 'js/[name]-[hash].js',
  42. entryFileNames: 'js/[name]-[hash].js',
  43. assetFileNames: 'assets/[name]-[hash].[ext]'
  44. }
  45. },
  46. terserOptions: { // 去掉打印
  47. compress: {
  48. drop_console: true,
  49. drop_debugger: true
  50. }
  51. }
  52. },
  53. })