// vite.config.mjs
import {
  defineConfig,
  loadEnv
} from "file:///Users/gxwebsoft/VUE/tms-erp-web-ws/node_modules/.pnpm/vite@5.4.21_sass@1.99.0_terser@5.46.2/node_modules/vite/dist/node/index.js";
import { resolve } from "path";

// vite/plugins/index.js
import vue from "file:///Users/gxwebsoft/VUE/tms-erp-web-ws/node_modules/.pnpm/@vitejs+plugin-vue@5.2.4_vite@5.4.21_sass@1.99.0_terser@5.46.2__vue@3.5.34/node_modules/@vitejs/plugin-vue/dist/index.mjs";

// vite/plugins/auto-import.js
import autoImport from "file:///Users/gxwebsoft/VUE/tms-erp-web-ws/node_modules/.pnpm/unplugin-auto-import@0.11.5_@vueuse+core@14.3.0_vue@3.5.34__rollup@4.60.3/node_modules/unplugin-auto-import/dist/vite.js";
function createAutoImport() {
  return autoImport({
    imports: ["vue", "vue-router", "vuex"],
    dts: false
  });
}

// vite/plugins/compression.js
import compression from "file:///Users/gxwebsoft/VUE/tms-erp-web-ws/node_modules/.pnpm/vite-plugin-compression@0.5.1_vite@5.4.21_sass@1.99.0_terser@5.46.2_/node_modules/vite-plugin-compression/dist/index.mjs";
function createCompression(env) {
  const { VITE_BUILD_COMPRESS } = env;
  const plugin = [];
  if (VITE_BUILD_COMPRESS) {
    const compressList = VITE_BUILD_COMPRESS.split(",");
    if (compressList.includes("gzip")) {
      plugin.push(
        compression({
          ext: ".gz",
          deleteOriginFile: false
        })
      );
    }
    if (compressList.includes("brotli")) {
      plugin.push(
        compression({
          ext: ".br",
          algorithm: "brotliCompress",
          deleteOriginFile: false
        })
      );
    }
  }
  return plugin;
}

// vite/plugins/setup-extend.js
import setupExtend from "file:///Users/gxwebsoft/VUE/tms-erp-web-ws/node_modules/.pnpm/vite-plugin-vue-setup-extend@0.4.0_vite@5.4.21_sass@1.99.0_terser@5.46.2_/node_modules/vite-plugin-vue-setup-extend/dist/index.mjs";
function createSetupExtend() {
  return setupExtend();
}

// vite/plugins/index.js
function createVitePlugins(viteEnv, isBuild = false) {
  const vitePlugins = [vue()];
  vitePlugins.push(createAutoImport());
  vitePlugins.push(createSetupExtend());
  isBuild && vitePlugins.push(...createCompression(viteEnv));
  return vitePlugins;
}

// vite.config.mjs
var __vite_injected_original_dirname = "/Users/gxwebsoft/VUE/tms-erp-web-ws";
var vite_config_default = ({
  mode,
  command
}) => {
  const env = loadEnv(mode, process.cwd());
  const {
    VITE_APP_ENV,
    VITE_APP_BASE
  } = env;
  const isProd = VITE_APP_ENV === "production";
  const buildConfig = {
    target: "esnext",
    minify: isProd ? "terser" : "esbuild"
    // 根据环境选择压缩工具
  };
  if (isProd) {
    buildConfig.terserOptions = {
      compress: {
        drop_console: true,
        // 删除 console
        drop_debugger: true
        // 删除 debugger
      },
      format: {
        comments: false
        // 删除所有注释
      }
    };
    buildConfig.rollupOptions = {
      output: {
        manualChunks: {
          "element-plus": ["element-plus"],
          "@smallwei/avue": ["@smallwei/avue"]
        }
      }
    };
  }
  return defineConfig({
    base: VITE_APP_BASE,
    define: {
      __VUE_I18N_FULL_INSTALL__: true,
      __VUE_I18N_LEGACY_API__: true,
      __INTLIFY_PROD_DEVTOOLS__: false
    },
    server: {
      port: 2888,
      proxy: {
        "/api": {
          target: "http://172.16.203.228:8000",
          changeOrigin: true
        }
      }
    },
    resolve: {
      alias: {
        "~": resolve(__vite_injected_original_dirname, "./"),
        "@": resolve(__vite_injected_original_dirname, "./src"),
        components: resolve(__vite_injected_original_dirname, "./src/components"),
        styles: resolve(__vite_injected_original_dirname, "./src/styles"),
        utils: resolve(__vite_injected_original_dirname, "./src/utils")
      }
    },
    css: {
      preprocessorOptions: {
        scss: {
          api: "modern-compiler",
          additionalData: `@use "@/styles/variables.scss" as *;`
        }
      }
    },
    plugins: createVitePlugins(env, command === "build"),
    build: buildConfig,
    optimizeDeps: {
      esbuildOptions: {
        target: "esnext"
      }
    }
  });
};
export {
  vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,[encoded data, 10332 characters]
