// vite.config.ts
import { URL, fileURLToPath } from "node:url";
import { defineConfig, loadEnv } from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/vite@5.2.11_@types+node@20._f0b6044236c2fac3c6bf28a869e2569e/node_modules/vite/dist/node/index.js";

// config/plugins/index.ts
import vue from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/@vitejs+plugin-vue@5.2.1_vi_83d378aaf413964320c6719ca0342f5b/node_modules/@vitejs/plugin-vue/dist/index.mjs";
import vueJsx from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/@vitejs+plugin-vue-jsx@3.1._60c9a05292828e383f3557263251a81c/node_modules/@vitejs/plugin-vue-jsx/dist/index.mjs";

// config/plugins/app-info.ts
import boxen from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/boxen@7.1.1/node_modules/boxen/index.js";
import picocolors from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/picocolors@1.0.1/node_modules/picocolors/picocolors.js";
function appInfo() {
  return {
    name: "appInfo",
    apply: "serve",
    async buildStart() {
      const { bold, green, cyan, bgGreen, underline } = picocolors;
      console.log(
        boxen(
          `${bold(green(`${bgGreen("ContiNew Admin v4.0.0-SNAPSHOT")}`))}
${cyan("\u5728\u7EBF\u6587\u6863\uFF1A")}${underline("https://continew.top")}
${cyan("\u5E38\u89C1\u95EE\u9898\uFF1A")}${underline("https://continew.top/admin/faq.html")}
${cyan("\u6301\u7EED\u8FED\u4EE3\u4F18\u5316\u7684\u524D\u540E\u7AEF\u5206\u79BB\u4E2D\u540E\u53F0\u7BA1\u7406\u7CFB\u7EDF\u6846\u67B6\u3002")}`,
          {
            padding: 1,
            margin: 1,
            borderStyle: "double",
            textAlignment: "center"
          }
        )
      );
    }
  };
}

// config/plugins/devtools.ts
import VueDevTools from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/vite-plugin-vue-devtools@7._2c536acb7f6c9fec478b2537f2af9668/node_modules/vite-plugin-vue-devtools/dist/vite.mjs";
function createDevtools(env) {
  const { VITE_OPEN_DEVTOOLS } = env;
  return VITE_OPEN_DEVTOOLS === "true" && VueDevTools();
}

// config/plugins/auto-import.ts
import autoImport from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/unplugin-auto-import@0.16.7_ac0a74eddef514a221699f49b31672a1/node_modules/unplugin-auto-import/dist/vite.js";
function createAutoImport() {
  return autoImport({
    // 自动导入 vue 相关函数
    imports: ["vue", "vue-router", {
      // vue 3.5.x
      vue: ["useTemplateRef", "onWatcherCleanup", "useId"]
    }],
    dts: "./src/types/auto-imports.d.ts"
  });
}

// config/plugins/components.ts
import components from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/unplugin-vue-components@0.2_d40b79480936da3a2c5b449ea0385fd9/node_modules/unplugin-vue-components/dist/vite.mjs";
function createComponents() {
  return components({
    // 指定组件位置，默认是 src/components 自动导入自定义组件
    dirs: ["src/components"],
    extensions: ["vue", "tsx"],
    // 配置文件生成位置
    dts: "./src/types/components.d.ts"
  });
}

// config/plugins/svg-icon.ts
import path from "node:path";
import process2 from "node:process";
import { createSvgIconsPlugin } from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/vite-plugin-svg-icons@2.0.1_95d604656676bf2393ecbead0d4ea21f/node_modules/vite-plugin-svg-icons/dist/index.mjs";
function createSvgIcon(isBuild) {
  return createSvgIconsPlugin({
    // 指定需要缓存的图标文件夹
    iconDirs: [path.resolve(process2.cwd(), "src/assets/icons")],
    // 指定 symbolId 格式
    symbolId: "icon-[dir]-[name]",
    svgoOptions: isBuild
  });
}

// config/plugins/mock.ts
import { viteMockServe } from "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/node_modules/.pnpm/vite-plugin-mock@2.9.8_mock_7e60745d1ec5a8eb989ff764476f5d68/node_modules/vite-plugin-mock/dist/index.js";
function createMock(env, isBuild) {
  const { VITE_BUILD_MOCK } = env;
  return viteMockServe({
    mockPath: "src/mock",
    // 目录位置
    logger: !isBuild,
    //  是否在控制台显示请求日志
    supportTs: true,
    // 是否读取 ts 文件模块
    localEnabled: true,
    // 设置是否启用本地mock文件
    prodEnabled: isBuild && VITE_BUILD_MOCK === "true",
    // 设置打包是否启用mock功能
    // 这样可以控制关闭mock的时候不让mock打包到最终代码内
    injectCode: `
          import { setupProdMockServer } from '../src/mock/index';
          setupProdMockServer();
        `
  });
}

// config/plugins/index.ts
function createVitePlugins(viteEnv, isBuild = false) {
  const vitePlugins = [appInfo(), vue(), vueJsx()];
  vitePlugins.push(createDevtools(viteEnv));
  vitePlugins.push(createAutoImport());
  vitePlugins.push(createComponents());
  vitePlugins.push(createSvgIcon(isBuild));
  vitePlugins.push(createMock(viteEnv, isBuild));
  return vitePlugins;
}

// vite.config.ts
var __vite_injected_original_import_meta_url = "file:///C:/Users/22214/Desktop/%E6%99%BA%E8%83%BD%E5%B9%B3%E5%8F%B0/Industrial-image-management-system---web/vite.config.ts";
var vite_config_default = defineConfig(({ command, mode }) => {
  const env = loadEnv(mode, process.cwd());
  return {
    // 开发或生产环境服务的公共基础路径
    base: env.VITE_BASE,
    // 路径别名
    resolve: {
      alias: {
        "~": fileURLToPath(new URL("./", __vite_injected_original_import_meta_url)),
        "@": fileURLToPath(new URL("./src", __vite_injected_original_import_meta_url))
      }
    },
    // 引入sass全局样式变量
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "@/styles/var.scss" as *;`,
          api: "modern-compiler"
        }
      }
    },
    // 添加需要vite优化的依赖
    optimizeDeps: {
      include: ["vue-draggable-plus"]
    },
    server: {
      // 服务启动时是否自动打开浏览器
      open: true,
      // 本地跨域代理 -> 代理到服务器的接口地址
      proxy: {
        [env.VITE_API_PREFIX]: {
          target: env.VITE_API_BASE_URL,
          // 后台服务器地址
          changeOrigin: true,
          // 是否允许不同源
          secure: false,
          // 支持https
          rewrite: (path2) => path2.replace(new RegExp(`^${env.VITE_API_PREFIX}`), "")
        }
      }
    },
    plugins: createVitePlugins(env, command === "build"),
    // 构建
    build: {
      chunkSizeWarningLimit: 2e3,
      // 消除打包大小超过500kb警告
      outDir: "dist",
      // 指定打包路径，默认为项目根目录下的dist目录
      minify: "terser",
      // Vite 2.6.x 以上需要配置 minify："terser"，terserOptions才能生效
      terserOptions: {
        compress: {
          keep_infinity: true,
          // 防止 Infinity 被压缩成 1/0，这可能会导致 Chrome 上的性能问题
          drop_console: true,
          // 生产环境去除 console
          drop_debugger: true
          // 生产环境去除 debugger
        },
        format: {
          comments: false
          // 删除注释
        }
      },
      // 静态资源打包到dist下的不同目录
      rollupOptions: {
        output: {
          chunkFileNames: "static/js/[name]-[hash].js",
          entryFileNames: "static/js/[name]-[hash].js",
          assetFileNames: "static/[ext]/[name]-[hash].[ext]"
        }
      }
    },
    // 以 envPrefix 开头的环境变量会通过 import.meta.env 暴露在你的客户端源码中。
    envPrefix: ["VITE", "FILE"]
  };
});
export {
  vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,[encoded data, 20308 characters]
