config.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /* eslint-disable react/destructuring-assignment */
  2. // https://umijs.org/config/
  3. const pageRoutes = require('./router.config');
  4. const path = require('path');
  5. export default {
  6. // add for transfer to umi
  7. plugins: [
  8. ['umi-plugin-react', {
  9. antd: true,
  10. dva: {
  11. hmr: true,
  12. },
  13. locale: {
  14. enable: true, // default false
  15. default: 'zh-CN', // default zh-CN
  16. baseNavigator: true, // default true, when it is true, will use `navigator.language` overwrite default
  17. },
  18. dll: [
  19. 'dva',
  20. 'dva/router',
  21. 'dva/saga',
  22. 'dva/fetch',
  23. ],
  24. }],
  25. ],
  26. // 路由配置
  27. routes: pageRoutes,
  28. theme: {
  29. 'card-actions-background': '#f5f8fa',
  30. },
  31. externals: {
  32. '@antv/data-set': 'DataSet',
  33. rollbar: 'rollbar',
  34. },
  35. alias: {
  36. components: path.resolve(__dirname, '../src/components/'),
  37. utils: path.resolve(__dirname, '../src/utils/'),
  38. assets: path.resolve(__dirname, '../src/assets/'),
  39. common: path.resolve(__dirname, '../src/common/'),
  40. },
  41. ignoreMomentLocale: true,
  42. lessLoaderOptions: {
  43. javascriptEnabled: true,
  44. },
  45. cssLoaderOptions: {
  46. modules: true,
  47. getLocalIdent: (context, localIdentName, localName) => {
  48. if (
  49. context.resourcePath.includes('node_modules') ||
  50. context.resourcePath.includes('ant.design.pro.less')
  51. ) {
  52. return localName;
  53. }
  54. const match = context.resourcePath.match(/src(.*)/);
  55. if (match && match[1]) {
  56. const antdProPath = match[1].replace('.less', '');
  57. const arr = antdProPath
  58. .split('/')
  59. .map(a => a.replace(/([A-Z])/g, '-$1'))
  60. .map(a => a.toLowerCase());
  61. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  62. } else {
  63. return localName;
  64. }
  65. },
  66. },
  67. manifest: {
  68. name: 'ant-design-pro',
  69. background_color: '#FFF',
  70. description: 'An out-of-box UI solution for enterprise applications as a React boilerplate.',
  71. display: 'standalone',
  72. start_url: '/index.html',
  73. icons: [
  74. {
  75. src: '/favicon.png',
  76. sizes: '48x48',
  77. type: 'image/png',
  78. },
  79. ],
  80. },
  81. chainWebpack(config) {
  82. const AntDesignThemePlugin = require('antd-theme-webpack-plugin');
  83. const MergeLessPlugin = require('antd-pro-merge-less');
  84. // 将所有 less 合并为一个供 themePlugin使用
  85. const outFile = path.join(__dirname, './.temp/ant-design-pro.less');
  86. const stylesDir = path.join(__dirname, './src/');
  87. // config
  88. // .plugin('merge-less')
  89. // .use(MergeLessPlugin, [{
  90. // stylesDir,
  91. // outFile,
  92. // }]);
  93. // config
  94. // .plugin('ant-design-theme')
  95. // .use(AntDesignThemePlugin, [{
  96. // antDir: path.join(__dirname, './node_modules/antd'),
  97. // stylesDir,
  98. // varFile: path.join(__dirname, './node_modules/antd/lib/style/themes/default.less'),
  99. // mainLessFile: outFile,
  100. // themeVariables: ['@primary-color'],
  101. // indexFileName: 'index.html',
  102. // }]);
  103. },
  104. };