vite.config.ts 1.3 KB

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