config.js 2.9 KB
Newer Older
ๆ„š้“'s avatar
ๆ„š้“ committed
1
// https://umijs.org/config/
2 3
import os from 'os';
import pageRoutes from './router.config';
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
4
import webpackPlugin from './plugin.config';
5
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
    [
      'umi-plugin-react',
      {
        antd: true,
        dva: {
          hmr: true,
        },
17
        targets: {
ๅๅณ's avatar
ๅๅณ committed
18
          ie: 11,
19
        },
้™ˆๅธ…'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
    [
      'umi-plugin-ga',
      {
        code: 'UA-72788897-6',
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
43
        judge: () => process.env.APP_TYPE === 'site',
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
44 45
      },
    ],
ๆ„š้“'s avatar
ๆ„š้“ committed
46
  ],
47 48 49
  targets: {
    ie: 11,
  },
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
50
  define: {
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
51
    APP_TYPE: process.env.APP_TYPE || '',
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
52
  },
ๆ„š้“'s avatar
ๆ„š้“ committed
53
  // ่ทฏ็”ฑ้…็ฝฎ
54
  routes: pageRoutes,
afc163's avatar
afc163 committed
55 56
  // Theme for antd
  // https://ant.design/docs/react/customize-theme-cn
ๆ„š้“'s avatar
ๆ„š้“ committed
57
  theme: {
afc163's avatar
afc163 committed
58
    'primary-color': defaultSettings.primaryColor,
ๆ„š้“'s avatar
ๆ„š้“ committed
59
  },
60 61 62
  externals: {
    '@antv/data-set': 'DataSet',
  },
้™ˆๅธ…'s avatar
้™ˆๅธ… committed
63 64 65 66 67 68 69
  // proxy: {
  //   '/server/api/': {
  //     target: 'https://preview.pro.ant.design/',
  //     changeOrigin: true,
  //     pathRewrite: { '^/server': '' },
  //   },
  // },
70 71 72 73
  ignoreMomentLocale: true,
  lessLoaderOptions: {
    javascriptEnabled: true,
  },
74
  disableRedirectHoist: true,
75 76 77 78 79
  cssLoaderOptions: {
    modules: true,
    getLocalIdent: (context, localIdentName, localName) => {
      if (
        context.resourcePath.includes('node_modules') ||
80 81
        context.resourcePath.includes('ant.design.pro.less') ||
        context.resourcePath.includes('global.less')
82 83 84
      ) {
        return localName;
      }
sorrycc's avatar
sorrycc committed
85 86 87 88 89 90 91 92 93
      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
94
      return localName;
95 96
    },
  },
97 98 99 100 101 102 103 104 105 106 107 108 109 110
  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
111

้™ˆๅธ…'s avatar
้™ˆๅธ… committed
112
  chainWebpack: webpackPlugin,
sorrycc's avatar
sorrycc committed
113 114 115
  cssnano: {
    mergeRules: false,
  },
ๆ„š้“'s avatar
ๆ„š้“ committed
116
};