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

ๆ„š้“'s avatar
ๆ„š้“ committed
3
// https://umijs.org/config/
4 5

const path = require('path');
xiaohu's avatar
xiaohu committed
6
const pageRoutes = require('../src/pages/_routes');
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
    [
      'umi-plugin-routes',
      {
        exclude: [/\.test\.js/],
xiaohu's avatar
xiaohu committed
17 18 19
        update(routes) {
          return [...pageRoutes, ...routes];
        },
ๆ„š้“'s avatar
ๆ„š้“ committed
20 21 22 23
      },
    ],
  ],
  disableServiceWorker: true,
24

ๆ„š้“'s avatar
ๆ„š้“ committed
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
  // ่ทฏ็”ฑ้…็ฝฎ
  // TODO ./src/pages ๅคชๅ†—ไฝ™ไบ†
  // routes: [{
  //   path: '/',
  //   component: './src/layouts/BasicLayout',
  //   indexRoute: { redirect: '/dashboard/analysis' },
  //   childRoutes: [

  //     // dashboard
  //     { path: 'dashboard/analysis', component: './src/pages/Dashboard/Analysis' },
  //     { path: 'dashboard/monitor', component: './src/pages/Dashboard/Monitor' },
  //     { path: 'dashboard/workplace', component: './src/pages/Dashboard/Workplace' },

  //     // forms
  //     { path: 'form/basic-form', component: './src/pages/Forms/BasicForm' },
  //     {
  //       path: 'form/step-form',
  //       component: './src/pages/Forms/StepForm',
  //       indexRoute: { redirect: '/form/step-form/info' },
  //       childRoutes: [
  //         { path: 'info', component: './src/pages/Forms/StepForm/Step1' },
  //         { path: 'confirm', component: './src/pages/Forms/StepForm/Step2' },
  //         { path: 'result', component: './src/pages/Forms/StepForm/Step3' },
  //       ],
  //     },
  //     { path: 'form/advanced-form', component: './src/pages/Forms/AdvancedForm' },

  //     // list
  //     { path: 'list/table-list', component: './src/pages/List/TableList' },
  //     { path: 'list/table-list', component: './src/pages/List/TableList' },
  //     { path: 'list/basic-list', component: './src/pages/List/BasicList' },
  //     { path: 'list/card-list', component: './src/pages/List/CardList' },
  //     {
  //       path: 'list/search',
  //       component: './src/pages/List/List',
  //       indexRoute: { redirect: '/list/search/projects' },
  //       childRoutes: [
  //         { path: 'articles', component: './src/pages/List/Articles' },
  //         { path: 'projects', component: './src/pages/List/Projects' },
  //         { path: 'applications', component: './src/pages/List/Applications' },
  //       ],
  //     },

  //     // profile
  //     { path: 'profile/basic', component: './src/pages/Profile/BasicProfile' },
  //     { path: 'profile/advanced', component: './src/pages/Profile/AdvancedProfile' },

  //     // result
  //     { path: 'result/success', component: './src/pages/Result/Success' },
  //     { path: 'result/fail', component: './src/pages/Result/Error' },

  //     // exception
  //     { path: 'exception/403', component: './src/pages/Exception/403' },
  //     { path: 'exception/404', component: './src/pages/Exception/404' },
  //     { path: 'exception/500', component: './src/pages/Exception/500' },

  // //   ],
  // }],

ๆ„š้“'s avatar
ๆ„š้“ committed
84 85 86
  // copy from old webpackrc.js

  // entry: 'src/index.js', // TODO remove
87 88 89 90 91 92 93 94 95 96 97 98
  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
99
    components: path.resolve(__dirname, '../src/components/'),
xiaohu's avatar
xiaohu committed
100 101 102
    utils: path.resolve(__dirname, '../src/utils/'),
    assets: path.resolve(__dirname, '../src/assets/'),
    common: path.resolve(__dirname, '../src/common/'),
103 104 105
  },
  ignoreMomentLocale: true,
  theme: './src/theme.js',
106 107 108
  // html: { TODO remove
  //   template: './src/index.ejs',
  // },
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
  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
132
};