vite.config.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import eslint from 'vite-plugin-eslint'
  4. import viteCompression from 'vite-plugin-compression'
  5. import path from 'path'
  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: '0.0.0.0',
  21. port: 5888,
  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. },
  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. define: {
  53. __VUE_OPTIONS_API__: false
  54. }
  55. })