// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
import { gameDataStatistics, gsData } from './routerConfig';
// const CompressionWebpackPlugin = require('compression-webpack-plugin');
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  history: {
    type: 'hash',
  },
  // 默认是 browse
  hash: true,
  antd: {
    // dark: true
    // compact: true, // 开启紧凑主题
  },
  dva: {
    hmr: true,
  },
  layout: {
    name: '趣程游戏数据系统',
    locale: false,
    siderWidth: 208,
  },
  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',
      layout: false,
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },
    gameDataStatistics, // 游戏数据
    gsData,  // gs数据
    {
      path: '/',
      redirect: '/',
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[(REACT_APP_ENV || 'dev') as keyof typeof proxy],
  manifest: {
    basePath: '/',
  },
});
