vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. import viteCompression from 'vite-plugin-compression'
  6. // https://vitejs.dev/config/
  7. export default defineConfig({
  8. base: './',
  9. resolve: {
  10. alias: {
  11. /*
  12. 路径别名
  13. 若为文件系统路径必须是绝对路径的形式,否则将以别名原样呈现,不会解析为文件系统路径路径
  14. */
  15. '@': path.resolve(__dirname, './src')
  16. }
  17. },
  18. plugins: [vue(), viteCompression(), eslint({ fix: true, include: ['**/*.ts', '**/*.vue'] })],
  19. server: {
  20. host: 'localhost',
  21. port: 6547,
  22. open: true,
  23. strictPort: false,
  24. https: false
  25. // 反向代理
  26. // proxy: {
  27. // '/': {
  28. // target: 'http://172.16.1.215:5000',
  29. // changeOrigin: true,
  30. // rewrite: (path) => path.replace(/^\//, '')
  31. // },
  32. // }
  33. },
  34. build: {
  35. rollupOptions: {
  36. input: {
  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. define: {
  54. __VUE_OPTIONS_API__: false
  55. }
  56. })