123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- import { fileURLToPath, URL } from 'node:url'
- import { defineConfig } from 'vite'
- import vue from '@vitejs/plugin-vue'
- import AutoImport from 'unplugin-auto-import/vite'
- import Components from 'unplugin-vue-components/vite'
- import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
- import commonjs from 'vite-plugin-commonjs';
- // https://vitejs.dev/config/
- export default defineConfig({
- publicDir: "public",
- base: './',
- server: {
- open: true,
- cors: true,
- proxy: {
- // 代理所有 /api 的请求,该求情将被代理到 target 中
- '/api2': {
- // 代理请求之后的请求地址(你的真实接口地址)
- // target: 'http://10.108.3.5:8080/cmnw_server_dev/api',
- target: 'http://10.244.107.145:8081/cmnw_server_dev/api',
- secure: false,
- ws: true,
- // 跨域
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api2/, ''),
- configure: (proxy) => {
- proxy.on('proxyReq', function (proxyReq) {
- proxyReq.removeHeader('referer')
- proxyReq.removeHeader('origin')
- proxyReq.setHeader('host','10.108.3.5:8080')
- // proxyReq.setHeader('host','10.244.107.145:8081')
- })
- },
- },
- '/api3': {
- // 代理请求之后的请求地址(你的真实接口地址)
- target: 'http://10.108.3.5:8080',
- // target: 'http://61.172.176.217:8081/',
- secure: false,
- ws: true,
- // 跨域
- changeOrigin: true,
- rewrite: (path) => path.replace(/^\/api3/, ''),
- // configure: (proxy) => {
- // proxy.on('proxyReq', function (proxyReq) {
- // proxyReq.removeHeader('referer')
- // proxyReq.removeHeader('origin')
- // // proxyReq.setHeader('host','10.108.3.5:8080')
- // proxyReq.setHeader('host','10.244.107.145:8081')
- // })
- // },
- },
- },
- // port: 8080,
- },
- plugins: [
- vue(),
- AutoImport({
- resolvers: [ElementPlusResolver()],
- }),
- Components({
- resolvers: [ElementPlusResolver()],
- }),
- commonjs({
- include: /utils\/map\/CityGis.Bridge.js/, // 包含的文件路径
- exclude: [], // 排除的文件路径
- extensions: ['.js'], // 需要转换的文件扩展名
- ignoreGlobal: false, // 是否忽略全局变量(例如 Buffer)
- sourceMap: false, // 是否生成源映射
- namedExports: {}, // 命名导出(名称和值)
- ignore: [], // 忽略文件的正则表达式
- transformMixedEsModules: true, // 是否转换混合的 ES 模块
- })
- ],
- build: {
- outDir: 'cmnw_xmsb',
- commonjsOptions: {
- include: /node_modules|utils\/map\/CityGis.Bridge.js/,
- }
- },
- resolve: {
- alias: {
- '@': fileURLToPath(new URL('./src', import.meta.url))
- }
- }
- })
|