vite.config.js 906 B

1234567891011121314151617181920212223242526272829303132333435
  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: 'https://dev3.k12100.net/teaching/api/', // 目标后端服务器地址
  28. // target: 'https://www.k12100.com/teaching/api/',
  29. changeOrigin: true, // 是否改变源
  30. // rewrite: (path) => path.replace(/^\/api/, '/') // 重写路径
  31. rewrite: (path) => path.endsWith('.js') ? '' : path.replace(/^\/api/, '/')
  32. }
  33. }
  34. }
  35. })