config.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /* eslint-disable react/destructuring-assignment */
  2. // https://umijs.org/config/
  3. const path = require('path');
  4. export default {
  5. // add for transfer to umi
  6. plugins: [
  7. 'umi-plugin-dva',
  8. [
  9. 'umi-plugin-routes',
  10. {
  11. exclude: [/\.test\.js/],
  12. },
  13. ],
  14. ],
  15. disableServiceWorker: true,
  16. // copy from old webpackrc.js
  17. // entry: 'src/index.js', // TODO remove
  18. extraBabelPlugins: [['import', { libraryName: 'antd', libraryDirectory: 'es', style: true }]],
  19. env: {
  20. development: {
  21. extraBabelPlugins: ['dva-hmr'],
  22. },
  23. },
  24. externals: {
  25. '@antv/data-set': 'DataSet',
  26. bizcharts: 'BizCharts',
  27. rollbar: 'rollbar',
  28. },
  29. alias: {
  30. components: path.resolve(__dirname, '../src/components/'),
  31. },
  32. ignoreMomentLocale: true,
  33. theme: './src/theme.js',
  34. html: {
  35. template: './src/index.ejs',
  36. },
  37. publicPath: '/',
  38. // TODO check hash config
  39. // hash: true,
  40. lessLoaderOptions: {
  41. javascriptEnabled: true,
  42. },
  43. cssLoaderOptions: {
  44. modules: true,
  45. getLocalIdent: (context, localIdentName, localName) => {
  46. if (
  47. context.resourcePath.includes('node_modules') ||
  48. context.resourcePath.includes('ant.design.pro.less')
  49. ) {
  50. return localName;
  51. }
  52. const antdProPath = context.resourcePath.match(/src(.*)/)[1].replace('.less', '');
  53. const arr = antdProPath
  54. .split('/')
  55. .map(a => a.replace(/([A-Z])/g, '-$1'))
  56. .map(a => a.toLowerCase());
  57. return `antd-pro${arr.join('-')}-${localName}`.replace(/--/g, '-');
  58. },
  59. },
  60. };