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

ๆ„š้“'s avatar
ๆ„š้“ committed
3
// https://umijs.org/config/
4
const pageRoutes = require('./router.config');
5 6
const path = require('path');

ๆ„š้“'s avatar
ๆ„š้“ committed
7
export default {
ๆ„š้“'s avatar
ๆ„š้“ committed
8 9
  // add for transfer to umi
  plugins: [
10 11
    'umi-plugin-dva',
    'umi-plugin-locale',
ๆ„š้“'s avatar
ๆ„š้“ committed
12
    // TODO ๅ†ณๅฎšๆ˜ฏๅฆไฝฟ็”จ็บฆๅฎš่ทฏ็”ฑ๏ผŒๅฆ‚ๆžœไฝฟ็”จ้…็ฝฎ่ทฏ็”ฑ้‚ฃไนˆ umi-plugin-routes ๅฏไปฅๅŽปๆŽ‰ไบ†
ๆ„š้“'s avatar
ๆ„š้“ committed
13 14 15 16 17 18 19 20 21
    // [
    //   'umi-plugin-routes',
    //   {
    //     exclude: [/\.test\.js/],
    //     update(routes) {
    //       return [...pageRoutes, ...routes];
    //     },
    //   },
    // ],
ๆ„š้“'s avatar
ๆ„š้“ committed
22
  ],
23 24 25 26 27 28
  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
    antd: true, // use antd, default is true
  },
ๆ„š้“'s avatar
ๆ„š้“ committed
29
  // ่ทฏ็”ฑ้…็ฝฎ
30
  routes: pageRoutes,
ๆ„š้“'s avatar
ๆ„š้“ committed
31

ๆ„š้“'s avatar
ๆ„š้“ committed
32 33 34
  theme: {
    'card-actions-background': '#f5f8fa',
  },
35 36
  // entry: 'src/index.js', // TODO remove
  extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
37 38 39 40 41 42 43 44 45 46
  env: {
    development: {
      extraBabelPlugins: ['dva-hmr'],
    },
  },
  externals: {
    '@antv/data-set': 'DataSet',
    rollbar: 'rollbar',
  },
  alias: {
ๆ„š้“'s avatar
ๆ„š้“ committed
47
    components: path.resolve(__dirname, '../src/components/'),
xiaohu's avatar
xiaohu committed
48 49 50
    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 64 65 66 67 68 69 70 71 72
  },
  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, '-');
    },
  },
73
  disableFastClick: true,
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
};