config.js 2.28 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 6
const path = require('path');

愚道's avatar
愚道 committed
7
export default {
愚道's avatar
愚道 committed
8 9
  // add for transfer to umi
  plugins: [
chencheng's avatar
chencheng committed
10 11 12 13 14 15 16 17 18 19 20
    [
      'umi-plugin-react',
      {
        dva: true,
        antd: true,
        locale: {
          default: 'zh-CN', // default zh-CN
          baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
        },
      },
    ],
愚道's avatar
愚道 committed
21
    // TODO 决定是否使用约定路由,如果使用配置路由那么 umi-plugin-routes 可以去掉了
愚道's avatar
愚道 committed
22 23 24 25 26 27 28 29 30
    // [
    //   'umi-plugin-routes',
    //   {
    //     exclude: [/\.test\.js/],
    //     update(routes) {
    //       return [...pageRoutes, ...routes];
    //     },
    //   },
    // ],
愚道's avatar
愚道 committed
31
  ],
愚道's avatar
愚道 committed
32
  // 路由配置
陈帅's avatar
陈帅 committed
33
  routes: pageRoutes,
愚道's avatar
愚道 committed
34

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