// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
import { adMonitor, launchSystem, launchSystemV3 } from './routerConfig';
// const CompressionWebpackPlugin = require('compression-webpack-plugin');
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  headScripts: [
    { src: 'https://unpkg.com/mediainfo.js', type: "text/javascript" }
  ],
  metas: [
    { httpEquiv: 'Content-Security-Policy', content: "script-src 'self' *.alibaba-inc.com *.dingtalk.com *.alicdn.com *.alipay.com" }
  ],
  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',
        },
      ],
    },
    // operatePage, //运营配置
    // dataStatistics, //数据中心配置
    launchSystem, // 投放系统
    launchSystemV3,
    adMonitor, // 广告监控
    // enterpriseWeChat,//企业微信
    {
      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: '/',
  },
});
