config.js 5.57 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 5

const path = require('path');
愚道's avatar
愚道 committed
6
// const pageRoutes = require('../_routes');
愚道's avatar
愚道 committed
7

愚道's avatar
愚道 committed
8
export default {
愚道's avatar
愚道 committed
9 10 11
  // add for transfer to umi
  plugins: [
    'umi-plugin-dva',
愚道'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
  ],
  disableServiceWorker: true,
愚道's avatar
愚道 committed
24

愚道's avatar
愚道 committed
25
  // 路由配置
愚道's avatar
愚道 committed
26 27 28
  routes: [
    {
      path: '/',
愚道's avatar
愚道 committed
29
      component: './layouts/LoadingPage',
愚道's avatar
愚道 committed
30 31 32 33 34 35
      routes: [
        // dashboard
        { path: '/', redirect: '/dashboard/analysis' },
        { path: '/dashboard/analysis', component: './Dashboard/Analysis' },
        { path: '/dashboard/monitor', component: './Dashboard/Monitor' },
        { path: '/dashboard/workplace', component: './Dashboard/Workplace' },
愚道's avatar
愚道 committed
36

愚道's avatar
愚道 committed
37 38 39 40 41 42 43 44 45 46 47 48 49
        // forms
        { path: '/form/basic-form', component: './Forms/BasicForm' },
        {
          path: '/form/step-form',
          component: './Forms/StepForm',
          routes: [
            { path: '/form/step-form', redirect: '/form/step-form/info' },
            { path: '/form/step-form/info', component: './Forms/StepForm/Step1' },
            { path: '/form/step-form/confirm', component: './Forms/StepForm/Step2' },
            { path: '/form/step-form/result', component: './Forms/StepForm/Step3' },
          ],
        },
        { path: '/form/advanced-form', component: './Forms/AdvancedForm' },
愚道's avatar
愚道 committed
50

愚道's avatar
愚道 committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
        // list
        { path: '/list/table-list', component: './List/TableList' },
        { path: '/list/table-list', component: './List/TableList' },
        { path: '/list/basic-list', component: './List/BasicList' },
        { path: '/list/card-list', component: './List/CardList' },
        {
          path: '/list/search',
          component: './List/List',
          routes: [
            { path: '/list/search', redirect: '/list/search/projects' },
            { path: '/list/search/articles', component: './List/Articles' },
            { path: '/list/search/projects', component: './List/Projects' },
            { path: '/list/search/applications', component: './List/Applications' },
          ],
        },
愚道's avatar
愚道 committed
66

愚道's avatar
愚道 committed
67 68 69
        // profile
        { path: '/profile/basic', component: './Profile/BasicProfile' },
        { path: '/profile/advanced', component: './Profile/AdvancedProfile' },
愚道's avatar
愚道 committed
70

愚道's avatar
愚道 committed
71 72 73
        // result
        { path: '/result/success', component: './Result/Success' },
        { path: '/result/fail', component: './Result/Error' },
愚道's avatar
愚道 committed
74

愚道's avatar
愚道 committed
75 76 77 78
        // exception
        { path: '/exception/403', component: './Exception/403' },
        { path: '/exception/404', component: './Exception/404' },
        { path: '/exception/500', component: './Exception/500' },
愚道's avatar
愚道 committed
79

愚道's avatar
愚道 committed
80
        // account
愚道's avatar
愚道 committed
81
        {
愚道's avatar
愚道 committed
82
          path: '/account/center',
愚道's avatar
愚道 committed
83 84
          component: './Account/Center/Center',
          routes: [
愚道's avatar
愚道 committed
85 86 87 88
            { path: '/account/center', redirect: '/account/center/articles' },
            { path: '/account/center/articles', component: './Account/Center/Articles' },
            { path: '/account/center/applications', component: './Account/Center/Applications' },
            { path: '/account/center/projects', component: './Account/Center/Projects' },
愚道's avatar
愚道 committed
89 90 91
          ],
        },
        {
愚道's avatar
愚道 committed
92
          path: '/account/settings',
愚道's avatar
愚道 committed
93 94
          component: './Account/Settings/Info',
          routes: [
愚道's avatar
愚道 committed
95 96 97 98
            { path: '/account/settings', redirect: '/account/settings/base' },
            { path: '/account/settings/base', component: './Account/Settings/BaseView' },
            { path: '/account/settings/security', component: './Account/Settings/SecurityView' },
            { path: '/account/settings/binding', component: './Account/Settings/BindingView' },
愚道's avatar
愚道 committed
99
            {
愚道's avatar
愚道 committed
100
              path: '/account/settings/notification',
愚道's avatar
愚道 committed
101 102 103 104
              component: './Account/Settings/NotificationView',
            },
          ],
        },
愚道's avatar
愚道 committed
105 106

        // user
愚道's avatar
愚道 committed
107 108 109
      ],
    },
  ],
愚道's avatar
愚道 committed
110

愚道's avatar
愚道 committed
111 112 113 114 115
  // https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less
  theme: {
    // 'primary-color': '#10e99b',
    'card-actions-background': '#f5f8fa',
  },
愚道's avatar
愚道 committed
116

愚道's avatar
愚道 committed
117 118 119
  // copy from old webpackrc.js

  // entry: 'src/index.js', // TODO remove
愚道's avatar
愚道 committed
120 121 122 123 124 125 126 127 128 129 130 131
  extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
  env: {
    development: {
      extraBabelPlugins: ['dva-hmr'],
    },
  },
  externals: {
    '@antv/data-set': 'DataSet',
    bizcharts: 'BizCharts',
    rollbar: 'rollbar',
  },
  alias: {
愚道's avatar
愚道 committed
132
    components: path.resolve(__dirname, '../src/components/'),
xiaohu's avatar
xiaohu committed
133 134 135
    utils: path.resolve(__dirname, '../src/utils/'),
    assets: path.resolve(__dirname, '../src/assets/'),
    common: path.resolve(__dirname, '../src/common/'),
愚道's avatar
愚道 committed
136 137
  },
  ignoreMomentLocale: true,
愚道's avatar
愚道 committed
138
  // theme: './theme.js',
愚道's avatar
愚道 committed
139
  // html: { TODO remove
愚道's avatar
愚道 committed
140
  //   template: './index.ejs',
愚道's avatar
愚道 committed
141
  // },
愚道's avatar
愚道 committed
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
  publicPath: '/',
  // TODO check hash config
  // hash: 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, '-');
    },
  },
愚道's avatar
愚道 committed
165
};