config.js 2.37 KB
Newer Older
愚道's avatar
愚道 committed
1 2
/* eslint-disable react/destructuring-assignment */

愚道's avatar
愚道 committed
3
// https://umijs.org/config/
陈帅's avatar
陈帅 committed
4
const pageRoutes = require('./router.config');
陈帅's avatar
陈帅 committed
5
const webpackplugin = require('./plugin.config');
愚道's avatar
愚道 committed
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
        },
23 24 25 26 27 28 29 30
        ...(
          require('os').platform() === 'darwin'
          ? {
              dll: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
              hardSource: true,
            }
          : {}
        ),
sorrycc's avatar
sorrycc committed
31
      },
陈帅's avatar
陈帅 committed
32
    ],
愚道's avatar
愚道 committed
33
  ],
愚道's avatar
愚道 committed
34
  // 路由配置
陈帅's avatar
陈帅 committed
35
  routes: pageRoutes,
愚道's avatar
愚道 committed
36

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

陈帅's avatar
陈帅 committed
91
  chainWebpack: webpackplugin,
愚道's avatar
愚道 committed
92
};