config.js 2.82 KB
Newer Older
愚道's avatar
愚道 committed
1
// https://umijs.org/config/
愚道's avatar
愚道 committed
2 3 4 5
import os from 'os';
import pageRoutes from './router.config';
import webpackplugin from './plugin.config';
import defaultSettings from '../src/defaultSettings';
愚道's avatar
愚道 committed
6

愚道's avatar
愚道 committed
7
export default {
愚道's avatar
愚道 committed
8 9
  // add for transfer to umi
  plugins: [
陈帅's avatar
陈帅 committed
10 11 12 13 14 15 16
    [
      'umi-plugin-react',
      {
        antd: true,
        dva: {
          hmr: true,
        },
陈帅's avatar
陈帅 committed
17 18 19
        targets: {
          ie: 9,
        },
陈帅's avatar
陈帅 committed
20 21 22 23 24
        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
        },
25 26 27
        dynamicImport: {
          loadingComponent: './components/PageLoading/index',
        },
陈帅's avatar
陈帅 committed
28
        ...(!process.env.TEST && os.platform() === 'darwin'
29
          ? {
chencheng's avatar
chencheng committed
30 31 32 33
              dll: {
                include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
                exclude: ['@babel/runtime'],
              },
34 35
              hardSource: true,
            }
36
          : {}),
sorrycc's avatar
sorrycc committed
37
      },
陈帅's avatar
陈帅 committed
38
    ],
陈帅's avatar
陈帅 committed
39 40 41 42 43 44
    [
      'umi-plugin-ga',
      {
        code: 'UA-72788897-6',
      },
    ],
愚道's avatar
愚道 committed
45
  ],
46 47 48
  targets: {
    ie: 11,
  },
陈帅's avatar
陈帅 committed
49
  define: {
陈帅's avatar
陈帅 committed
50
    APP_TYPE: process.env.APP_TYPE || '',
陈帅's avatar
陈帅 committed
51
  },
愚道's avatar
愚道 committed
52
  // 路由配置
陈帅's avatar
陈帅 committed
53
  routes: pageRoutes,
afc163's avatar
afc163 committed
54 55
  // Theme for antd
  // https://ant.design/docs/react/customize-theme-cn
愚道's avatar
愚道 committed
56
  theme: {
afc163's avatar
afc163 committed
57
    'primary-color': defaultSettings.primaryColor,
愚道's avatar
愚道 committed
58
  },
愚道's avatar
愚道 committed
59 60 61
  externals: {
    '@antv/data-set': 'DataSet',
  },
陈帅's avatar
陈帅 committed
62 63 64 65 66 67 68
  // proxy: {
  //   '/server/api/': {
  //     target: 'https://preview.pro.ant.design/',
  //     changeOrigin: true,
  //     pathRewrite: { '^/server': '' },
  //   },
  // },
愚道's avatar
愚道 committed
69 70 71 72 73 74 75 76 77
  ignoreMomentLocale: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
      if (
        context.resourcePath.includes('node_modules') ||
陈帅's avatar
陈帅 committed
78 79
        context.resourcePath.includes('ant.design.pro.less') ||
        context.resourcePath.includes('global.less')
愚道's avatar
愚道 committed
80 81 82
      ) {
        return localName;
      }
sorrycc's avatar
sorrycc committed
83 84 85 86 87 88 89 90 91
      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, '-');
      }
陈帅's avatar
陈帅 committed
92
      return localName;
愚道's avatar
愚道 committed
93 94
    },
  },
95 96 97 98 99 100 101 102 103 104 105 106 107 108
  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
109

陈帅's avatar
陈帅 committed
110
  chainWebpack: webpackplugin,
sorrycc's avatar
sorrycc committed
111 112 113
  cssnano: {
    mergeRules: false,
  },
愚道's avatar
愚道 committed
114
};