config.js 2.46 KB
Newer Older
1 2
/* eslint-disable react/destructuring-assignment */

ๆ„š้“'s avatar
ๆ„š้“ committed
3
// https://umijs.org/config/
4
const pageRoutes = require('./router.config');
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
5
const webpackplugin = require('./plugin.config');
6 7
const path = require('path');

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

ๆ„š้“'s avatar
ๆ„š้“ committed
38 39 40
  theme: {
    'card-actions-background': '#f5f8fa',
  },
41 42 43 44
  externals: {
    '@antv/data-set': 'DataSet',
    rollbar: 'rollbar',
  },
45 46 47 48 49 50
  alias: {
    components: path.resolve(__dirname, '../src/components/'),
    utils: path.resolve(__dirname, '../src/utils/'),
    assets: path.resolve(__dirname, '../src/assets/'),
    common: path.resolve(__dirname, '../src/common/'),
  },
51 52 53 54 55 56 57 58 59 60 61 62 63
  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
64 65 66 67 68 69 70 71 72 73 74
      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;
      }
75 76
    },
  },
77 78 79 80 81 82 83 84 85 86 87 88 89 90
  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
91

้™ˆๅธ…'s avatar
้™ˆๅธ… committed
92
  chainWebpack: webpackplugin,
sorrycc's avatar
sorrycc committed
93 94 95
  cssnano: {
    mergeRules: false,
  },
ๆ„š้“'s avatar
ๆ„š้“ committed
96
};