config.js 2.3 KB
Newer Older
愚道 已提交
1
// https://umijs.org/config/
陈帅 已提交
2
const os = require('os');
陈帅 已提交
3
const pageRoutes = require('./router.config');
陈帅 已提交
4
const webpackplugin = require('./plugin.config');
5
const defaultSetting = require('../src/defaultSetting');
愚道 已提交
6

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

陈帅 已提交
83
  chainWebpack: webpackplugin,
S
sorrycc 已提交
84 85 86
  cssnano: {
    mergeRules: false,
  },
愚道 已提交
87
};