config.js 2.21 KB
Newer Older
愚道's avatar
愚道 committed
1
// https://umijs.org/config/
陈帅's avatar
陈帅 committed
2
const pageRoutes = require('./router.config');
陈帅's avatar
陈帅 committed
3
const webpackplugin = require('./plugin.config');
4
const defaultSetting = require('../src/defaultSetting');
愚道's avatar
愚道 committed
5

愚道's avatar
愚道 committed
6
export default {
愚道's avatar
愚道 committed
7 8
  // add for transfer to umi
  plugins: [
陈帅's avatar
陈帅 committed
9 10 11 12 13 14 15 16 17 18 19 20
    [
      '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
        },
21 22
        dynamicImport: true,
        polyfills: ['ie11'],
23
        ...(!process.env.TEST && require('os').platform() === 'darwin'
24 25 26 27
          ? {
              dll: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
              hardSource: true,
            }
28
          : {}),
sorrycc's avatar
sorrycc committed
29
      },
陈帅's avatar
陈帅 committed
30
    ],
愚道's avatar
愚道 committed
31
  ],
愚道's avatar
愚道 committed
32
  // 路由配置
陈帅's avatar
陈帅 committed
33
  routes: pageRoutes,
34
  // theme for antd
愚道's avatar
愚道 committed
35
  theme: {
36
    'primary-color': defaultSetting.primaryColor,
愚道's avatar
愚道 committed
37
  },
愚道's avatar
愚道 committed
38 39 40 41 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') ||
        context.resourcePath.includes('ant.design.pro.less')
      ) {
        return localName;
      }
sorrycc's avatar
sorrycc committed
54 55 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, '-');
      } else {
        return localName;
      }
愚道's avatar
愚道 committed
65 66
    },
  },
67 68 69 70 71 72 73 74 75 76 77 78 79 80
  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
81

陈帅's avatar
陈帅 committed
82
  chainWebpack: webpackplugin,
sorrycc's avatar
sorrycc committed
83 84 85
  cssnano: {
    mergeRules: false,
  },
愚道's avatar
愚道 committed
86
};