config.js 2.12 KB
Newer Older
ๆ„š้“'s avatar
ๆ„š้“ committed
1
// https://umijs.org/config/
2
const pageRoutes = require('./router.config');
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
3
const webpackplugin = require('./plugin.config');
4

ๆ„š้“'s avatar
ๆ„š้“ committed
5
export default {
ๆ„š้“'s avatar
ๆ„š้“ committed
6 7
  // add for transfer to umi
  plugins: [
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
8 9 10 11 12 13 14 15 16 17 18 19
    [
      '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
        },
sorrycc's avatar
sorrycc committed
20
        polyfills: ['ie9'],
21
        ...(!process.env.TEST && require('os').platform() === 'darwin'
22 23 24 25
          ? {
              dll: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
              hardSource: true,
            }
26
          : {}),
sorrycc's avatar
sorrycc committed
27
      },
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
28
    ],
ๆ„š้“'s avatar
ๆ„š้“ committed
29
  ],
ๆ„š้“'s avatar
ๆ„š้“ committed
30
  // ่ทฏ็”ฑ้…็ฝฎ
31
  routes: pageRoutes,
ๆ„š้“'s avatar
ๆ„š้“ committed
32

ๆ„š้“'s avatar
ๆ„š้“ committed
33 34 35
  theme: {
    'card-actions-background': '#f5f8fa',
  },
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
  externals: {
    '@antv/data-set': 'DataSet',
    rollbar: 'rollbar',
  },
  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
53 54 55 56 57 58 59 60 61 62 63
      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;
      }
64 65
    },
  },
66 67 68 69 70 71 72 73 74 75 76 77 78 79
  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
80

้™ˆๅธ…'s avatar
้™ˆๅธ… committed
81
  chainWebpack: webpackplugin,
sorrycc's avatar
sorrycc committed
82 83 84
  cssnano: {
    mergeRules: false,
  },
ๆ„š้“'s avatar
ๆ„š้“ committed
85
};