config.js 1.3 KB

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