vite.config.js 955 B

123456789101112131415161718192021222324252627282930313233343536
  1. import {
  2. defineConfig
  3. } from 'vite'
  4. import uni from '@dcloudio/vite-plugin-uni'
  5. import path from 'path'
  6. const define = {
  7. __VUE_PROD_DEVTOOLS__: 'false'
  8. }
  9. if (!["mp-weixin", "h5", "web"].includes(process.env.UNI_PLATFORM)) {
  10. define['global'] = '{}'
  11. define['wx'] = 'uni'
  12. }
  13. export default defineConfig({
  14. resolve: {
  15. alias: {
  16. '@': path.resolve(__dirname, '.')
  17. }
  18. },
  19. plugins: [uni()],
  20. define,
  21. // base: process.env.NODE_ENV === 'production' ? './' : '/',
  22. // transpileDependencies: ['@dcloudio/uni-ui'],
  23. server: {
  24. port: 8088,
  25. proxy: {
  26. '/api': {
  27. // target: 'http://192.168.1.32:47001/api/',
  28. target: 'https://dev3.k12100.net/teaching/api/', // 目标后端服务器地址
  29. // target: 'https://www.k12100.com/teaching/api/',
  30. changeOrigin: true, // 是否改变源
  31. // rewrite: (path) => path.replace(/^\/api/, '/') // 重写路径
  32. rewrite: (path) => path.endsWith('.js') ? '' : path.replace(/^\/api/, '/')
  33. }
  34. }
  35. }
  36. })