vite.config.js 2.1 KB

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