vite.config.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import {
  2. defineConfig
  3. } from 'vite'
  4. import vue from '@vitejs/plugin-vue'
  5. import WindiCSS from 'vite-plugin-windicss'
  6. import Components from 'unplugin-vue-components/vite'
  7. import {
  8. ElementPlusResolver
  9. } from 'unplugin-vue-components/resolvers'
  10. import {
  11. resolve
  12. } from 'path';
  13. const pathResolve = (dir) => {
  14. return resolve(__dirname, '.', dir);
  15. };
  16. const alias = {
  17. '@': pathResolve('./src/'),
  18. '@tools': pathResolve('./src/tools'),
  19. '@api': pathResolve('./src/api'),
  20. '@com': pathResolve('./src/components'),
  21. '/@': pathResolve('./src/'),
  22. };
  23. // https://vitejs.dev/config/
  24. export default defineConfig({
  25. base: process.env.ELECTRON == "true" ? './' : "./",
  26. resolve: {
  27. alias
  28. },
  29. build: {
  30. sourcemap: false
  31. },
  32. optimizeDeps: {
  33. include: ["element-plus/lib/locale/lang/zh-cn"],
  34. },
  35. plugins: [
  36. Components({
  37. resolvers: [ElementPlusResolver()],
  38. }),
  39. WindiCSS(),
  40. vue()
  41. ],
  42. server: {
  43. host: '0.0.0.0',
  44. open: false, //自动打开
  45. base: "./ ", //生产环境路径
  46. proxy: { // 本地开发环境通过代理实现跨域,生产环境使用 nginx 转发
  47. // // 正则表达式写法
  48. // '^/sharding': {
  49. // // target: 'http://10.155.32.14:8082/sharding',
  50. // target: 'http://192.168.10.8:9002',
  51. // changeOrigin: true, //开启代理
  52. // rewrite: (path) => path.replace(/^\/sharding/, '')
  53. // },
  54. // '^/adapter': {
  55. // // target: 'http://10.155.32.14:8082/sharding',
  56. // target: 'http://192.168.10.8:9002',
  57. // changeOrigin: true, //开启代理
  58. // rewrite: (path) => path.replace(/^\/adapter/, '')
  59. // },
  60. // '^/current': {
  61. // // target: 'http://10.155.32.14:8082/sharding',
  62. // target: 'http://192.168.10.8:9002',
  63. // changeOrigin: true, //开启代理
  64. // rewrite: (path) => path.replace(/^\/current/, '')
  65. // },
  66. }
  67. },
  68. })