import { defineConfig } from "umi";
import { join } from "path";
import { readdirSync } from "fs";

const getIcons = () => {
  const iconDir = join(__dirname, "src/icons");
  return readdirSync(iconDir)
    .filter(file => file.endsWith(".svg"))
    .map(file => `local:${file.replace(/\.svg$/, "")}`);
};

export default defineConfig({
  routes: [
    { path: "/", redirect: "/login" },
    { path: "/login", component: "@/routes/login/login" },
    {
      path: "/indexPage",
      component: "@/routes/indexPage",
      routes: [{ path: "*" }],
    },
    {
      path: "/loginMobile",
      component: "@/routes/mobile/login/LoginMobile",
    },

    {
      path: "/indexMobile",
      component: "@/routes/mobile/IndexMobile",
      routes: [{ path: "*" }],
    },
  ],
  title: "小羚羊EBC前台业务系统",
  favicons: ["/favicon.ico"],
  npmClient: "pnpm",
  dva: {},
  icons: {
    include: getIcons(),
  },
  plugins: ["@umijs/plugins/dist/dva"],
  mfsu: false,
  hash: true,
});
