vite.config.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import { defineConfig } from 'vite'
  2. import uni from '@dcloudio/vite-plugin-uni'
  3. // https://vitejs.dev/config/
  4. export default defineConfig({
  5. build: {
  6. // 开发阶段启用源码映射:https://uniapp.dcloud.net.cn/tutorial/migration-to-vue3.html#需主动开启-sourcemap
  7. sourcemap: process.env.NODE_ENV === 'development',
  8. },
  9. plugins: [
  10. uni(),
  11. {
  12. // 自定义插件禁用vite:vue插件的devToolsEnabled,强制编译 vue 模板时 inline 为 true
  13. name: 'fix-vite-plugin-vue',
  14. configResolved(config) {
  15. const plugin = config.plugins.find((p) => p.name === 'vite:vue')
  16. if (plugin && plugin.api && plugin.api.options) {
  17. plugin.api.options.devToolsEnabled = false
  18. }
  19. },
  20. },
  21. ],
  22. server: {
  23. // host: 'c3j6u3.natappfree.cc',
  24. host: '0.0.0.0',
  25. port: 80,
  26. // https: false,
  27. //设置法反向代理跨域
  28. // proxy: {
  29. // '/api': {
  30. // //后台地址
  31. // target: '',
  32. // changeOrigin: true,
  33. // rewrite: (path) => path.replace(/^\/api1/, ''),
  34. // },
  35. // },
  36. proxy: {
  37. '/api': {
  38. // target: 'http://i9p32r.natappfree.cc',
  39. target: 'http://n823va.natappfree.cc',
  40. changeOrigin: true,
  41. rewrite: (path) => path.replace(/^\/api/, ''),
  42. },
  43. },
  44. // proxy: {
  45. // '/api': {
  46. // target: 'http://localhost:90',
  47. // changeOrigin: true,
  48. // pathRewrite: {
  49. // '^/api': '',
  50. // },
  51. // },
  52. // },
  53. },
  54. })