import { fileURLToPath, URL } from 'node:url' import { resolve } from 'node:path' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' import vueDevTools from 'vite-plugin-vue-devtools' import postcssPresetEnv from 'postcss-preset-env' import postcssNormalizeCharset from 'postcss-normalize-charset' import autoprefixer from 'autoprefixer' function pathResolve(dir: string) { return resolve(__dirname, dir) } const URL_USE = 'http://172.18.32.98:8888' // const URL_USE = 'http://172.18.32.98:11439' // const URL_USE = 'http://192.168.0.46:11439' // const URL_USE = 'http://222.190.139.186:14000' // https://vite.dev/config/ export default defineConfig({ server: { host: true, port: 3019, // 指定端口 strictPort: false, // 如果端口已被占用则退出 proxy: { '/api': { target: URL_USE, changeOrigin: true, // 修改请求的 origin rewrite: (path: string) => path, // 可选:重写路径 }, '/ollama': { target: URL_USE, changeOrigin: true, // 修改请求的 origin rewrite: (path: string) => path, // 可选:重写路径 }, '/openai': { target: URL_USE, changeOrigin: true, // 修改请求的 origin rewrite: (path: string) => path, // 可选:重写路径 }, '/ws': { target: URL_USE, changeOrigin: true, // 修改请求的 origin ws: true, rewrite: (path: string) => path, // 可选:重写路径 }, }, }, plugins: [ vue(), vueJsx(), vueDevTools(), ], resolve: { alias: [ { find: /\@\//, replacement: `${pathResolve('src')}/`, }, ] }, css: { postcss: { plugins:[ postcssPresetEnv(), postcssNormalizeCharset({ add: true, }), autoprefixer({ //css兼容前缀 overrideBrowserslist: [ 'Android 4.1', 'ios 7.1', 'Chrome >31', 'not ie <=11', //不考虑IE浏览器 'ff >= 30', //仅新版本用'ff >= 30 '>1%', //全球统计有超过1%的使用了使用'> 1%' 'last 2 version', //所有主流浏览器最近2个版本 ], grid: true, //开启grid布局的兼容(浏览器IE除外其它都能兼容grid,可以关闭开启) }), // px2rem({ // rootValue: 19.2, // UI设计稿的宽度/10 // // rootValue : 37.5, // unitPrecision: 3, // 转rem精确到小数点多少位 // propList: ['*'], // 需要转换的属性 *表示所有 // selectorBlackList: ['ignore'], // 不进行px转换的选择器 // replace: true, // 是否直接更换属性值,而不添加备用属性 // mediaQuery: false, // 是否在媒体查询的css代码中也进行转换 // minPixelValue: 0, // 设置要替换的最小像素值 // exclude: /node_modules/i // 排除node_modules文件夹下的文件 // }) ] }, preprocessorOptions: { scss: { }, }, } })