// vite.config.ts
import { defineConfig, loadEnv } from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/vite/dist/node/index.js";
import { resolve as resolve2 } from "path";

// build/getEnv.ts
function wrapperEnv(envConf) {
  const ret = {};
  for (const envName of Object.keys(envConf)) {
    let realName = envConf[envName].replace(/\\n/g, "\n");
    realName = realName === "true" ? true : realName === "false" ? false : realName;
    if (envName === "VITE_PORT")
      realName = Number(realName);
    if (envName === "VITE_PROXY") {
      try {
        realName = JSON.parse(realName);
      } catch (error) {
      }
    }
    ret[envName] = realName;
  }
  return ret;
}

// build/proxy.ts
function createProxy(list = []) {
  const ret = {};
  for (const [prefix, target] of list) {
    const httpsRE = /^https:\/\//;
    const isHttps = httpsRE.test(target);
    ret[prefix] = {
      target,
      changeOrigin: true,
      ws: true,
      rewrite: (path) => path.replace(new RegExp(`^${prefix}`), ""),
      // https is require secure=false
      ...isHttps ? { secure: false } : {}
    };
  }
  return ret;
}

// build/plugins.ts
import { resolve } from "path";
import { VitePWA } from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/vite-plugin-pwa/dist/index.js";
import { visualizer } from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/rollup-plugin-visualizer/dist/plugin/index.js";
import { createHtmlPlugin } from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/vite-plugin-html/dist/index.mjs";
import { createSvgIconsPlugin } from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/vite-plugin-svg-icons/dist/index.mjs";
import vue from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/@vitejs/plugin-vue/dist/index.mjs";
import vueJsx from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/@vitejs/plugin-vue-jsx/dist/index.mjs";
import eslintPlugin from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/vite-plugin-eslint/dist/index.mjs";
import viteCompression from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/vite-plugin-compression/dist/index.mjs";
import vueSetupExtend from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/unplugin-vue-setup-extend-plus/dist/vite.js";
import AutoImport from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/unplugin-auto-import/dist/vite.js";
import Components from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/unplugin-vue-components/dist/vite.mjs";
import { ElementPlusResolver } from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/unplugin-vue-components/dist/resolvers.mjs";
import Icons from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/unplugin-icons/dist/vite.mjs";
import IconsResolver from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/unplugin-icons/dist/resolver.mjs";
var createVitePlugins = (viteEnv) => {
  const { VITE_GLOB_APP_TITLE, VITE_REPORT, VITE_PWA } = viteEnv;
  return [
    vue(),
    // vue 可以使用 jsx/tsx 语法
    vueJsx(),
    // esLint 报错信息显示在浏览器界面上
    eslintPlugin(),
    // name 可以写在 script 标签上
    vueSetupExtend({}),
    // 创建打包压缩配置
    createCompression(viteEnv),
    // 注入变量到 html 文件
    createHtmlPlugin({
      inject: {
        data: { title: VITE_GLOB_APP_TITLE }
      }
    }),
    // 使用 svg 图标
    createSvgIconsPlugin({
      iconDirs: [resolve(process.cwd(), "src/assets/icons")],
      symbolId: "icon-[dir]-[name]"
    }),
    // element按需导入
    AutoImport({
      // 安装两行后你会发现在组件中不用再导入ref，reactive等
      imports: ["vue", "vue-router"],
      dts: "src/auto-import.d.ts",
      // element
      resolvers: [
        ElementPlusResolver({ importStyle: "sass" }),
        IconsResolver({
          prefix: "Icon"
        })
      ]
    }),
    Components({
      // element
      resolvers: [
        ElementPlusResolver({ importStyle: "sass" }),
        IconsResolver({
          enabledCollections: ["ep"]
        })
      ],
      // 默认存放位置
      dts: "src/components.d.ts"
    }),
    Icons({
      autoInstall: true
    }),
    // vitePWA
    VITE_PWA && createVitePwa(viteEnv),
    // 是否生成包预览，分析依赖包大小做优化处理
    VITE_REPORT && visualizer({ filename: "stats.html", gzipSize: true, brotliSize: true })
  ];
};
var createCompression = (viteEnv) => {
  const { VITE_BUILD_COMPRESS = "none", VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE } = viteEnv;
  const compressList = VITE_BUILD_COMPRESS.split(",");
  const plugins = [];
  if (compressList.includes("gzip")) {
    plugins.push(
      viteCompression({
        ext: ".gz",
        algorithm: "gzip",
        deleteOriginFile: VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE
      })
    );
  }
  if (compressList.includes("brotli")) {
    plugins.push(
      viteCompression({
        ext: ".br",
        algorithm: "brotliCompress",
        deleteOriginFile: VITE_BUILD_COMPRESS_DELETE_ORIGIN_FILE
      })
    );
  }
  return plugins;
};
var createVitePwa = (viteEnv) => {
  const { VITE_GLOB_APP_TITLE } = viteEnv;
  return VitePWA({
    registerType: "autoUpdate",
    manifest: {
      name: VITE_GLOB_APP_TITLE,
      short_name: VITE_GLOB_APP_TITLE,
      theme_color: "#ffffff",
      icons: [
        {
          src: "/logo.png",
          sizes: "192x192",
          type: "image/png"
        },
        {
          src: "/logo.png",
          sizes: "512x512",
          type: "image/png"
        },
        {
          src: "/logo.png",
          sizes: "512x512",
          type: "image/png",
          purpose: "any maskable"
        }
      ]
    }
  });
};

// package.json
var package_default = {
  name: "yc_ops_admin_ts",
  private: true,
  version: "1.0.0",
  type: "module",
  scripts: {
    dev: "vite",
    serve: "vite",
    "build:dev": "vue-tsc && vite build --mode development",
    "build:test": "vue-tsc && vite build --mode test",
    "build:pro": "vue-tsc && vite build --mode production",
    "type:check": "vue-tsc --noEmit --skipLibCheck",
    preview: "npm run build:dev && vite preview",
    "lint:eslint": "eslint --fix --ext .js,.ts,.vue ./src",
    "lint:prettier": 'prettier --write "src/**/*.{js,ts,json,tsx,css,less,scss,vue,html,md}"',
    "lint:stylelint": 'stylelint --cache --fix "**/*.{vue,less,postcss,css,scss}" --cache --cache-location node_modules/.cache/stylelint/',
    "lint:lint-staged": "lint-staged",
    prepare: "husky install",
    release: "standard-version",
    commit: "git add -A && czg && git push"
  },
  dependencies: {
    "@element-plus/icons-vue": "^2.1.0",
    "@types/decimal.js": "^7.4.0",
    "@vueuse/core": "^10.1.2",
    "@wangeditor/editor": "^5.1.23",
    "@wangeditor/editor-for-vue": "^5.1.12",
    "async-validator": "^4.2.5",
    axios: "^1.4.0",
    "bwip-js": "^4.3.2",
    dayjs: "^1.11.9",
    decimal: "^0.0.2",
    "default-passive-events": "^2.0.0",
    "driver.js": "^0.9.8",
    "element-plus": "^2.3.4",
    "file-saver": "^2.0.5",
    "js-md5": "^0.7.3",
    jsbarcode: "^3.11.6",
    jsonpack: "^1.1.5",
    "lodash-es": "^4.17.21",
    mitt: "^3.0.0",
    nprogress: "^0.2.0",
    pinia: "^2.1.3",
    "pinia-plugin-persistedstate": "^3.1.0",
    "print-js": "^1.6.0",
    qs: "^6.11.2",
    sortablejs: "^1.15.0",
    vue: "^3.3.4",
    "vue-router": "^4.2.2",
    vuedraggable: "^4.1.0",
    "vxe-table": "^4.5.0-beta.10",
    "xe-utils": "^3.5.11",
    xlsx: "^0.18.5"
  },
  devDependencies: {
    "@commitlint/cli": "^17.6.3",
    "@commitlint/config-conventional": "^17.6.3",
    "@iconify-json/ep": "^1.1.10",
    "@types/file-saver": "^2.0.5",
    "@types/js-md5": "^0.7.0",
    "@types/nprogress": "^0.2.0",
    "@types/qs": "^6.9.7",
    "@types/sortablejs": "^1.15.1",
    "@typescript-eslint/eslint-plugin": "^5.59.7",
    "@typescript-eslint/parser": "^5.59.7",
    "@vitejs/plugin-vue": "^4.2.3",
    "@vitejs/plugin-vue-jsx": "^3.0.1",
    autoprefixer: "^10.4.14",
    "cz-git": "^1.6.1",
    czg: "^1.6.1",
    eslint: "^8.41.0",
    "eslint-config-prettier": "^8.8.0",
    "eslint-plugin-prettier": "^4.2.1",
    "eslint-plugin-vue": "^9.14.0",
    husky: "^8.0.3",
    "lint-staged": "^13.2.2",
    postcss: "^8.4.23",
    "postcss-html": "^1.5.0",
    prettier: "^2.8.8",
    qrcode: "^1.5.3",
    "rollup-plugin-visualizer": "^5.9.0",
    sass: "^1.62.1",
    "standard-version": "^9.5.0",
    stylelint: "^15.6.2",
    "stylelint-config-html": "^1.1.0",
    "stylelint-config-recess-order": "^4.0.0",
    "stylelint-config-recommended-scss": "^12.0.0",
    "stylelint-config-recommended-vue": "^1.4.0",
    "stylelint-config-standard": "^33.0.0",
    "stylelint-config-standard-scss": "^9.0.0",
    typescript: "^5.0.2",
    "unplugin-auto-import": "^0.16.4",
    "unplugin-icons": "^0.16.3",
    "unplugin-vue-components": "^0.25.1",
    "unplugin-vue-setup-extend-plus": "^1.0.0",
    vite: "^4.3.9",
    "vite-plugin-compression": "^0.5.1",
    "vite-plugin-eslint": "^1.8.1",
    "vite-plugin-html": "^3.2.0",
    "vite-plugin-pwa": "^0.15.0",
    "vite-plugin-svg-icons": "^2.0.1",
    "vue-tsc": "^1.6.5"
  },
  engines: {
    node: ">=16.0.0"
  },
  browserslist: {
    production: [
      "> 1%",
      "not dead",
      "not op_mini all"
    ],
    development: [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  config: {
    commitizen: {
      path: "node_modules/cz-git"
    }
  }
};

// vite.config.ts
import dayjs from "file:///D:/new_ops/orico-supplier-ts-admin/node_modules/dayjs/dayjs.min.js";
var __vite_injected_original_dirname = "D:\\new_ops\\orico-supplier-ts-admin";
var { dependencies, devDependencies, name, version } = package_default;
var __APP_INFO__ = {
  pkg: { dependencies, devDependencies, name, version },
  lastBuildTime: dayjs().format("YYYY-MM-DD HH:mm:ss")
};
var vite_config_default = defineConfig(({ mode }) => {
  const root = process.cwd();
  const env = loadEnv(mode, root);
  const viteEnv = wrapperEnv(env);
  return {
    base: viteEnv.VITE_PUBLIC_PATH,
    root,
    resolve: {
      alias: {
        "@": resolve2(__vite_injected_original_dirname, "./src")
      }
    },
    define: {
      __APP_INFO__: JSON.stringify(__APP_INFO__)
    },
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: `@use "@/styles/var.scss" as *;`
        }
      }
    },
    server: {
      host: "0.0.0.0",
      port: viteEnv.VITE_PORT,
      open: viteEnv.VITE_OPEN,
      cors: true,
      // Load proxy configuration from .env.development
      proxy: createProxy(viteEnv.VITE_PROXY)
    },
    plugins: createVitePlugins(viteEnv),
    esbuild: {
      //"console.log",
      pure: viteEnv.VITE_DROP_CONSOLE ? ["console.log", "debugger"] : []
    },
    build: {
      outDir: "dist",
      minify: "esbuild",
      // esbuild 打包更快，但是不能去除 console.log，terser打包慢，但能去除 console.log
      // minify: "terser",
      // terserOptions: {
      // 	compress: {
      // 		drop_console: viteEnv.VITE_DROP_CONSOLE,
      // 		drop_debugger: true
      // 	}
      // },
      // 禁用 gzip 压缩大小报告，可略微减少打包时间
      reportCompressedSize: false,
      // 规定触发警告的 chunk 大小
      chunkSizeWarningLimit: 2e3,
      rollupOptions: {
        output: {
          // Static resource classification and packaging
          chunkFileNames: "assets/js/[name]-[hash].js",
          entryFileNames: "assets/js/[name]-[hash].js",
          assetFileNames: "assets/[ext]/[name]-[hash].[ext]"
        }
      }
    }
  };
});
export {
  vite_config_default as default
};
//# sourceMappingURL=data:application/json;base64,[encoded data, 30716 characters]
