vite.config.ts 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import path from 'path' // 引入 Node.js 的 path 模块
  4. // https://vite.dev/config/
  5. export default defineConfig({
  6. plugins: [vue()],
  7. resolve: {
  8. alias: {
  9. '@': path.resolve(__dirname, './src') // 配置 @ 指向 src 目录
  10. },
  11. extensions: ['.ts', '.js', '.vue', '.json'] // 添加这一行
  12. },
  13. build: {
  14. sourcemap: false, // 不生成 source map,隐藏源码
  15. minify: 'terser',
  16. terserOptions: {
  17. compress: {
  18. drop_console: true, // 移除所有 console 输出
  19. drop_debugger: true, // 移除 debugger 调试语句
  20. pure_funcs: ['console.log', 'console.info', 'console.warn', 'console.error'] // 移除指定的 console 函数
  21. }
  22. }
  23. },
  24. server: {
  25. host: '0.0.0.0',//允许所有ip访问
  26. port: 5731,//默认端口
  27. proxy:{
  28. // '/api':{
  29. // // target:'https://dev.k12100.net/admin/adminApi',
  30. // target:'https://dev3.k12100.net/teaching/api/',
  31. // changeOrigin:true,
  32. // rewrite:path => path.replace(/^\/api/, '')
  33. // },
  34. '/adminApi':{
  35. target:'https://admin.k12100.net/admin/adminApi',//测试
  36. // target:'https://admin.k12100.com/admin/adminApi',//线上
  37. // target:'http://192.168.1.61:47002/adminApi',
  38. changeOrigin:true,
  39. rewrite:path => path.replace(/^\/adminApi/, '')
  40. }
  41. },
  42. }//配置代理
  43. })