text: // https://umijs.org/config/
  import { defineConfig, utils } from 'umi';
  import defaultSettings from './defaultSettings';
  import proxy from './proxy';
  import webpackPlugin from './plugin.config';
  const { winPath } = utils; // preview.pro.ant.design only do not use in your production ;
  // preview.pro.ant.design 专用环境变量，请不要在你的项目中使用它。
  
  const { REACT_APP_ENV, GA_KEY } = process.env;
  export default defineConfig({
    hash: true,
    antd: {},
    analytics: GA_KEY
      ? {
          ga: GA_KEY,
        }
      : false,
    dva: {
      hmr: true,
    },
    locale: {
      // default zh-CN
      default: 'zh-CN',
      // default true, when it is true, will use `navigator.language` overwrite default
      antd: true,
      baseNavigator: true,
    },
    dynamicImport: {
      loading: '@/components/PageLoading/index',
    },
    targets: {
      ie: 11,
    },
    // umi routes: https://umijs.org/docs/routing
    routes: [
      {
        path: '/user',
        component: '../layouts/UserLayout',
        routes: [
          {
            name: '登录',
            path: '/user/login',
            component: './user/login',
          },
        ],
      },
      {
        path: '/',
        component: '../layouts/SecurityLayout',
        routes: [
          {
            path: '/',
            component: '../layouts/BasicLayout',
            authority: ['admin', 'user'],
            routes: [
              {
                path: '/',
                redirect: '/grade',
              },
              {
                name: '成绩',
                icon: 'table',
                path: '/grade',
                component: './grade',
              },
              {
                path: '/about',
                name: '关于本站',
                icon: 'smile',
                component: './Welcome',
              },
              {
                path: '/log',
                name: '更新日志',
                icon: 'FileExclamationOutlined',
                component: './updateLog'
              },
              {
                component: './404',
              },
            ],
          },
          {
            component: './404',
          },
        ],
      },
      {
        component: './404',
      },
    ],
    // Theme for antd: https://ant.design/docs/react/customize-theme-cn
    theme: {
      // ...darkTheme,
      'primary-color': defaultSettings.primaryColor,
    },
    define: {
      REACT_APP_ENV: REACT_APP_ENV || false, // preview.pro.ant.design only do not use in your production ; preview.pro.ant.design 专用环境变量，请不要在你的项目中使用它。
    },
    ignoreMomentLocale: true,
    lessLoader: {
      javascriptEnabled: true,
    },
    cssLoader: {
      modules: {
        getLocalIdent: (context, _, localName) => {
          if (
            context.resourcePath.includes('node_modules') ||
            context.resourcePath.includes('ant.design.pro.less') ||
            context.resourcePath.includes('global.less')
          ) {
            return localName;
          }
  
          const match = context.resourcePath.match(/src(.*)/);
  
          if (match && match[1]) {
            const antdProPath = match[1].replace('.less', '');
            const arr = winPath(antdProPath)
              .split('/')
              .map(a => a.replace(/([A-Z])/g, '-$1'))
              .map(a => a.toLowerCase());
            return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
          }
  
          return localName;
        },
      },
    },
    manifest: {
      basePath: '/',
    },
    proxy: proxy[REACT_APP_ENV || 'dev'],
    chainWebpack: webpackPlugin,
  });
  