1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- 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 的请求,该求情将被代理到 target 中
- '/api': {
- // 代理请求之后的请求地址(你的真实接口地址)
- target: 'https://datamidplat.zjw.sh.cegn.cn:2011/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','datamidplat.zjw.sh.cegn.cn:2011')
- })
- },
- }
- },
- },
- publicDir: "public",
- base: './',
- plugins: [
- vue(),
- commonjs({
- exclude: [], // 排除的文件路径
- extensions: ['.js'], // 需要转换的文件扩展名
- ignoreGlobal: false, // 是否忽略全局变量(例如 Buffer)
- sourceMap: false, // 是否生成源映射
- namedExports: {}, // 命名导出(名称和值)
- ignore: [], // 忽略文件的正则表达式
- transformMixedEsModules: true, // 是否转换混合的 ES 模块
- }),
- AutoImport({
- resolvers: [ElementPlusResolver()],
- }),
- Components({
- resolvers: [ElementPlusResolver()],
- }),
- ],
- build: {
- outDir: 'data-middleground',
- },
- resolve: {
- alias: {
- '@': fileURLToPath(new URL('./src', import.meta.url))
- }
- }
- })
|