| | |
| | | import { fileURLToPath, URL } from 'node:url' |
| | | |
| | | import { defineConfig } from 'vite' |
| | | import {fileURLToPath, URL} from 'node:url' |
| | | import {defineConfig} from 'vite' |
| | | import vue from '@vitejs/plugin-vue' |
| | | import ReactivityTransform from '@vue-macros/reactivity-transform/vite' |
| | | import AutoImport from 'unplugin-auto-import/vite' |
| | | |
| | | // https://vitejs.dev/config/ |
| | | export default defineConfig({ |
| | | plugins: [ |
| | | vue(), |
| | | ReactivityTransform() |
| | | ReactivityTransform(), |
| | | AutoImport({ |
| | | imports: [ |
| | | 'vue-i18n', |
| | | ], |
| | | dts: './auto-imports.d.ts', |
| | | eslintrc: { |
| | | enabled: false, // 配置更新时临时设为true, |
| | | }, |
| | | }), |
| | | ], |
| | | resolve: { |
| | | alias: { |
| | | 'vue-i18n': 'vue-i18n/dist/vue-i18n.cjs.js', |
| | | '@': fileURLToPath(new URL('./src', import.meta.url)) |
| | | } |
| | | }, |
| | | server: { |
| | | port: 801,//端口号 |
| | | host: true,//ip地址 或 '0.0.0.0' 或 "loaclhost" |
| | | open: false, //启动后是否自动打开浏览器 |
| | | https: false, // 是否开启 https |
| | | port: 801, |
| | | host: true, |
| | | open: false, |
| | | https: false, |
| | | proxy: { |
| | | '^/api': { |
| | | target: 'localhost:8080/mesModuleTools', //目标源,目标服务器,真实请求地址 |
| | | changeOrigin: true, //支持跨域 |
| | | rewrite: (path) => path.replace(/^\/api/, "/mesModuleTools"), //重写真实路径,替换/api |
| | | // pathRewrite: { |
| | | // '^/api': '' |
| | | // } |
| | | // rewrite: (path) => path.replace(/^\/api/, "/mesModuleTools"), //重写真实路径,替换/api |
| | | }, |
| | | '/api2': { |
| | | target: 'localhost:8080/mesModuleTools', |
| | | '/api': { |
| | | target: 'http://127.0.0.1:88/', |
| | | changeOrigin: true, |
| | | rewrite: (path) => path.replace(/^\/api2/, "mesModuleTools"), |
| | | rewrite: (path) => path.replace(/^\/api/, '/'), |
| | | }, |
| | | } |
| | | } |
| | | }) |
| | | // '/api2': { |
| | | // target: 'http://localhost:8085/mesModuleTools', |
| | | // changeOrigin: true, |
| | | // pathRewrite: { |
| | | // '^/api2': '', |
| | | // }, |
| | | // }, |
| | | }, |
| | | }, |
| | | configureServer: ({ middlewares }) => { |
| | | middlewares.use( |
| | | '/mesModuleTools', |
| | | createProxyMiddleware({ |
| | | target: 'ws://localhost:8081', |
| | | ws: true, |
| | | changeOrigin: true, |
| | | pathRewrite: { |
| | | '^/mesModuleTools': '', |
| | | }, |
| | | }) |
| | | ); |
| | | }, |
| | | }); |