vite.config.ts 960 B

123456789101112131415161718192021222324252627282930
  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. base: process.env.NODE_ENV === 'production' ? '/scoring/' : '/', // 添加这行配置
  7. plugins: [vue()],
  8. resolve: {
  9. alias: {
  10. '@': path.resolve(__dirname, './src') // 配置 @ 指向 src 目录
  11. },
  12. extensions: ['.ts', '.js', '.vue', '.json'] // 添加这一行
  13. },
  14. server: {
  15. host: '0.0.0.0',//允许所有ip访问
  16. port: 8088,//默认端口
  17. https:false,//是否开启https
  18. proxy:{
  19. '/api':{
  20. target:'https://dev3.k12100.net/teaching/api/',//测试环境
  21. // target:'http://192.168.1.48:47001/api/',//测试环境
  22. // target:'https://www.k12100.com/teaching/api/',//正式环境
  23. changeOrigin:true,
  24. rewrite:path => path.replace(/^\/api/, '')
  25. }
  26. },
  27. }//配置代理
  28. })