import * as path from "path";

const resolve = (dir) => path.resolve(__dirname, dir);
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
  server:{
    cors: true,
    resolve: {
      alias: {
        // 将 ArcGIS API 本地路径指向 node_modules 中的 `@arcgis/core`
        '@arcgis/core': path.resolve(__dirname, 'node_modules/@arcgis/core')
      }
    },
    proxy: {
      '/api': {
        // 代理请求之后的请求地址(你的真实接口地址)
        target: 'http://10.90.9.143:9252/',
        //target: 'http://localhost:9250/',
        secure: false,
        ws: true,
        // 跨域
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/api/, '')
      },
      '/zwapi': {
        // 代理请求之后的请求地址(你的真实接口地址)
        target: 'https://cimweb.zjw.sh.cegn.cn:2008/',
        //target: 'http://58.34.215.19:8095/low-altitude/DataSearch/',
        //target: 'http://localhost:9250/',
        secure: false,
        ws: true,
        // 跨域
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/zwapi/, '')
      },
      '/netapi': {
        // 代理请求之后的请求地址(你的真实接口地址)
        target: 'http://58.34.215.19:8095/low-altitude/',
        //target: 'http://10.1.161.53:8095/',
        //target: 'http://localhost:9250/',
        secure: false,
        ws: true,
        // 跨域
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\/netapi/, '')
      },
    }
  },
  plugins: [vue()],
  base:'/map-tool-widget/',
  publicDir: resolve('static'),
})