vite.dev.config.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. import {defineConfig} from "vite";
  2. import path from 'path';
  3. import vue from '@vitejs/plugin-vue'
  4. import AutoImport from 'unplugin-auto-import/vite';
  5. import { createHtmlPlugin } from 'vite-plugin-html';
  6. export default defineConfig({
  7. publicDir: path.resolve(__dirname + '/node_modules/icore-frame', './public'), // 将my-vue-app目录下的public文件复制到dist目录下
  8. // 开发服务器配置
  9. server: {
  10. // 服务器主机名,如果允许外部访问,可设置为 '0.0.0.0'
  11. host: '0.0.0.0',
  12. // 开发环境服务器端口号
  13. port: 3000,
  14. proxy: {
  15. '/xgjl/pass/auth': {
  16. //target: 'http://sso.steerinfo.com/auth',
  17. //target: 'http://sso.steerinfo.com/auth',
  18. target:'http://192.168.3.33/xgjl/pass/auth',
  19. changeOrigin: true,
  20. /**
  21. pathRewrite: {
  22. '^/icore.icp.web/pass/auth': '/'
  23. } */
  24. rewrite: (path) => path.replace(/^\/xgjl\/pass\/auth/, '/')
  25. },
  26. '/xgjl/pass/v1': {
  27. //target: 'http://sso.steerinfo.com/v1',
  28. target:'http://192.168.3.33/xgjl/pass/v1',
  29. changeOrigin: true,
  30. rewrite: (path) => path.replace(/^\/xgjl\/pass\/v1/, '/')
  31. },
  32. '/xgjl/pass/logout': {
  33. //target: 'http://sso.steerinfo.com/logout',
  34. target:'http://192.168.3.33/xgjl/pass/logout',
  35. changeOrigin: true,
  36. rewrite: (path) => path.replace(/^\/xgjl\/pass\/logout/, '/')
  37. },
  38. '/xgjl/pass/systemBase/v1': {
  39. target: 'http://192.168.3.33/xgjl/pass/systemBase/v1',
  40. //target: 'http://localhost:9004/v1',
  41. changeOrigin: true,
  42. rewrite: (path) => path.replace(/^\/xgjl\/pass\/systemBase\/v1/, '/')
  43. },
  44. /**
  45. '/views/' : {
  46. target: 'http://localhost:3000/node_modules/my-vue-app/views/',
  47. changeOrigin: true,
  48. rewrite: (path) => path.replace(/^\/views/, '/')
  49. } */
  50. /**
  51. '/views/': {
  52. target: 'http://127.0.0.1:3000', // 目标地址,这里设置为本地地址,因为是重定向到本地的不同路径
  53. changeOrigin: true,
  54. rewrite: (path) => {
  55. const pattern = /^\/views\/(?!(index|systemConfig)\.html$).*\.html$/;
  56. //const pattern = /^\/views\/(?!(index|systemConfig)\b).*$/;
  57. if (pattern.test(path)) {
  58. // 自己项目下的页面,统统走这里
  59. return path.replace('/views/', '/pages/');
  60. }
  61. // index,systemConfig模块走这里
  62. return path.replace('/views/', '/node_modules/icore-frame/pages/');
  63. }
  64. } */
  65. '/views/index.html': {
  66. target: 'http://127.0.0.1:3000',
  67. rewrite: (path) => path.replace('/views/index.html', '/node_modules/icore-frame/pages/index.html'),
  68. changeOrigin: true
  69. },
  70. '/views/systemConfig.html': {
  71. target: 'http://127.0.0.1:3000',
  72. rewrite: (path) => path.replace('/views/systemConfig.html', '/node_modules/icore-frame/pages/systemConfig.html'),
  73. changeOrigin: true
  74. }
  75. }
  76. },
  77. build:{
  78. rollupOptions:{
  79. input: {
  80. //'index' : '/views/index.html',
  81. //'systemConfig' : '/views/systemConfig.html',
  82. //'systemBase' : '/views/systemBase.html',
  83. // 'index' : '/node_modules/my-vue-app/views/index.html'
  84. //'index' : path.resolve(__dirname, '../../views/indexxx.html')
  85. }
  86. }
  87. },
  88. plugins: [
  89. vue(),
  90. AutoImport({
  91. imports: ['vue','vuex','vue-router'],
  92. dts: 'src/auto-imports.d.ts'
  93. }),
  94. ]
  95. });