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