config.js 2.59 KB
Newer Older
ๆ„š้“'s avatar
ๆ„š้“ committed
1
// https://umijs.org/config/
2 3 4 5
import os from 'os';
import pageRoutes from './router.config';
import webpackplugin from './plugin.config';
import defaultSettings from '../src/defaultSettings';
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 17 18 19 20 21
    [
      '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
        },
22 23 24
        dynamicImport: {
          loadingComponent: './components/PageLoading/index',
        },
25
        polyfills: ['ie11'],
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
26
        ...(!process.env.TEST && os.platform() === 'darwin'
27
          ? {
chencheng's avatar
chencheng committed
28 29 30 31
              dll: {
                include: ['dva', 'dva/router', 'dva/saga', 'dva/fetch'],
                exclude: ['@babel/runtime'],
              },
32 33
              hardSource: true,
            }
34
          : {}),
sorrycc's avatar
sorrycc committed
35
      },
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
36
    ],
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
37 38 39 40 41 42
    [
      'umi-plugin-ga',
      {
        code: 'UA-72788897-6',
      },
    ],
ๆ„š้“'s avatar
ๆ„š้“ committed
43
  ],
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
44
  define: {
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
45
    APP_TYPE: process.env.APP_TYPE || '',
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
46
  },
ๆ„š้“'s avatar
ๆ„š้“ committed
47
  // ่ทฏ็”ฑ้…็ฝฎ
48
  routes: pageRoutes,
afc163's avatar
afc163 committed
49 50
  // Theme for antd
  // https://ant.design/docs/react/customize-theme-cn
ๆ„š้“'s avatar
ๆ„š้“ committed
51
  theme: {
afc163's avatar
afc163 committed
52
    'primary-color': defaultSettings.primaryColor,
ๆ„š้“'s avatar
ๆ„š้“ committed
53
  },
54 55 56 57 58 59 60 61 62 63 64 65
  externals: {
    '@antv/data-set': 'DataSet',
  },
  ignoreMomentLocale: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
      if (
        context.resourcePath.includes('node_modules') ||
66 67
        context.resourcePath.includes('ant.design.pro.less') ||
        context.resourcePath.includes('global.less')
68 69 70
      ) {
        return localName;
      }
sorrycc's avatar
sorrycc committed
71 72 73 74 75 76 77 78 79
      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
80
      return localName;
81 82
    },
  },
83 84 85 86 87 88 89 90 91 92 93 94 95 96
  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
97

้™ˆๅธ…'s avatar
้™ˆๅธ… committed
98
  chainWebpack: webpackplugin,
sorrycc's avatar
sorrycc committed
99 100 101
  cssnano: {
    mergeRules: false,
  },
ๆ„š้“'s avatar
ๆ„š้“ committed
102
};