| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import { defineConfig } from "vite";
- import vue from "@vitejs/plugin-vue";
- import path from "path";
- import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
- const resolve = (dir) => path.join(__dirname, dir);
- // 获取时间戳
- const version = new Date().getTime();
- // https://vitejs.dev/config/
- export default defineConfig({
- plugins: [
- vue(),
- createSvgIconsPlugin({
- // 指定 SVG 图标目录(绝对路径)
- iconDirs: [path.resolve(process.cwd(), "src/assets/icons")],
- // 指定 symbolId 格式
- symbolId: "icon-[dir]-[name]",
- // 自定义插入位置(可选)
- inject: "body-last",
- }),
- ],
- resolve: {
- alias: {
- "@": resolve("src"),
- },
- },
- base: "/", // History 模式下必须用绝对路径,避免 /mcp/guide 等深层路由把 JS 解析成 /mcp/assets/...
- // 反向代理
- server: {
- port: 8060,
- host: "0.0.0.0",
- open: false, // 服务启动时是否自动打开浏览器true
- hmr: true, // 开启热更新
- cors: true, // 允许跨域
- proxy: {
- "/dev-api": {
- changeOrigin: true, //是否允许跨域
- // target: "https://ai.eiacloud.com/chat-api/", // 线上测试地址
- // target: "http://192.168.0.3:8021", // 本地测试地址
- target: "https://cktest.eiacloud.com/chat-api/", // 本地测试地址
- rewrite: (path) => path.replace(/^\/dev-api/, ""),
- },
- },
- },
- css: {
- preprocessorOptions: {
- less: {
- additionalData: `@import "${path.resolve(
- __dirname,
- "src/assets/styles/commonStyle.less"
- )}";`,
- },
- },
- },
- build: {
- // 配置输出文件名
- rollupOptions: {
- output: {
- // JS 文件添加时间戳
- entryFileNames: `assets/js/[name].${version}.js`,
- chunkFileNames: `assets/js/[name].${version}.js`,
- assetFileNames: `assets/css/[name].${version}.[ext]`, // CSS 文件添加时间戳
- },
- },
- },
- });
|