config.js 2.6 KB
Newer Older
愚道 已提交
1
// https://umijs.org/config/
愚道 已提交
2 3 4 5
import os from 'os';
import pageRoutes from './router.config';
import webpackplugin from './plugin.config';
import defaultSettings from '../src/defaultSettings';
愚道 已提交
6

愚道 已提交
7
export default {
愚道 已提交
8 9
  // add for transfer to umi
  plugins: [
陈帅 已提交
10 11 12 13 14 15 16
    [
      'umi-plugin-react',
      {
        antd: true,
        dva: {
          hmr: true,
        },
陈帅 已提交
17 18 19
        targets: {
          ie: 9,
        },
陈帅 已提交
20 21 22 23 24
        locale: {
          enable: true, // default false
          default: 'zh-CN', // default zh-CN
          baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
        },
A
afc163 已提交
25 26 27
        dynamicImport: {
          loadingComponent: './components/PageLoading/index',
        },
陈帅 已提交
28
        ...(!process.env.TEST && os.platform() === 'darwin'
S
sorrycc 已提交
29
          ? {
C
chencheng 已提交
30 31 32 33
              dll: {
                include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
                exclude: ['@babel/runtime'],
              },
S
sorrycc 已提交
34 35
              hardSource: true,
            }
36
          : {}),
S
sorrycc 已提交
37
      },
陈帅 已提交
38
    ],
陈帅 已提交
39 40 41 42 43 44
    [
      'umi-plugin-ga',
      {
        code: 'UA-72788897-6',
      },
    ],
愚道 已提交
45
  ],
Y
Yu 已提交
46 47 48
  targets: {
    ie: 11,
  },
陈帅 已提交
49
  define: {
陈帅 已提交
50
    APP_TYPE: process.env.APP_TYPE || '',
陈帅 已提交
51
  },
愚道 已提交
52
  // 路由配置
陈帅 已提交
53
  routes: pageRoutes,
A
afc163 已提交
54 55
  // Theme for antd
  // https://ant.design/docs/react/customize-theme-cn
愚道 已提交
56
  theme: {
A
afc163 已提交
57
    'primary-color': defaultSettings.primaryColor,
愚道 已提交
58
  },
愚道 已提交
59 60 61 62 63 64 65 66 67 68 69 70
  externals: {
    '@antv/data-set': 'DataSet',
  },
  ignoreMomentLocale: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
      if (
        context.resourcePath.includes('node_modules') ||
陈帅 已提交
71 72
        context.resourcePath.includes('ant.design.pro.less') ||
        context.resourcePath.includes('global.less')
愚道 已提交
73 74 75
      ) {
        return localName;
      }
S
sorrycc 已提交
76 77 78 79 80 81 82 83 84
      const match = context.resourcePath.match(/src(.*)/);
      if (match && match[1]) {
        const antdProPath = match[1].replace('.less', '');
        const arr = antdProPath
          .split('/')
          .map(a => a.replace(/([A-Z])/g, '-$1'))
          .map(a => a.toLowerCase());
        return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
      }
陈帅 已提交
85
      return localName;
愚道 已提交
86 87
    },
  },
88 89 90 91 92 93 94 95 96 97 98 99 100 101
  manifest: {
    name: 'ant-design-pro',
    background_color: '#FFF',
    description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
    display: 'standalone',
    start_url: '/index.html',
    icons: [
      {
        src: '/favicon.png',
        sizes: '48x48',
        type: 'image/png',
      },
    ],
  },
S
sorrycc 已提交
102

陈帅 已提交
103
  chainWebpack: webpackplugin,
S
sorrycc 已提交
104 105 106
  cssnano: {
    mergeRules: false,
  },
愚道 已提交
107
};