config.js 2.37 KB
Newer Older
愚道's avatar
愚道 committed
1
// https://umijs.org/config/
愚道's avatar
愚道 committed
2 3 4 5
import os from 'os';
import pageRoutes from './router.config';
import webpackplugin from './plugin.config';
import defaultSettings from '../src/defaultSettings';
愚道's avatar
愚道 committed
6

愚道's avatar
愚道 committed
7
export default {
愚道's avatar
愚道 committed
8 9
  // add for transfer to umi
  plugins: [
陈帅's avatar
陈帅 committed
10 11 12 13 14 15 16 17 18 19 20 21
    [
      'umi-plugin-react',
      {
        antd: true,
        dva: {
          hmr: true,
        },
        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
        },
22 23 24
        dynamicImport: {
          loadingComponent: './components/PageLoading/index',
        },
25
        polyfills: ['ie11'],
陈帅's avatar
陈帅 committed
26
        ...(!process.env.TEST && os.platform() === 'darwin'
27 28 29 30
          ? {
              dll: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
              hardSource: true,
            }
31
          : {}),
sorrycc's avatar
sorrycc committed
32
      },
陈帅's avatar
陈帅 committed
33
    ],
愚道's avatar
愚道 committed
34
  ],
愚道's avatar
愚道 committed
35
  // 路由配置
陈帅's avatar
陈帅 committed
36
  routes: pageRoutes,
afc163's avatar
afc163 committed
37 38
  // Theme for antd
  // https://ant.design/docs/react/customize-theme-cn
愚道's avatar
愚道 committed
39
  theme: {
afc163's avatar
afc163 committed
40
    'primary-color': defaultSettings.primaryColor,
愚道's avatar
愚道 committed
41
  },
愚道's avatar
愚道 committed
42 43 44 45 46 47 48 49 50 51 52 53
  externals: {
    '@antv/data-set': 'DataSet',
  },
  ignoreMomentLocale: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
      if (
        context.resourcePath.includes('node_modules') ||
陈帅's avatar
陈帅 committed
54 55
        context.resourcePath.includes('ant.design.pro.less') ||
        context.resourcePath.includes('global.less')
愚道's avatar
愚道 committed
56 57 58
      ) {
        return localName;
      }
sorrycc's avatar
sorrycc committed
59 60 61 62 63 64 65 66 67
      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, '-');
      }
陈帅's avatar
陈帅 committed
68
      return localName;
愚道's avatar
愚道 committed
69 70
    },
  },
71 72 73 74 75 76 77 78 79 80 81 82 83 84
  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',
      },
    ],
  },
sorrycc's avatar
sorrycc committed
85

陈帅's avatar
陈帅 committed
86
  chainWebpack: webpackplugin,
sorrycc's avatar
sorrycc committed
87 88 89
  cssnano: {
    mergeRules: false,
  },
愚道's avatar
愚道 committed
90
};