.webpackrc.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. const path = require('path');
  2. export default {
  3. entry: 'src/index.js',
  4. extraBabelPlugins: [
  5. [
  6. 'import',
  7. {
  8. libraryName: 'antd',
  9. libraryDirectory: 'es',
  10. style: true,
  11. },
  12. ],
  13. ],
  14. env: {
  15. development: {
  16. extraBabelPlugins: ['dva-hmr'],
  17. },
  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. disableDynamicImport: true,
  29. hash: true,
  30. lessLoaderOptions: {
  31. javascriptEnabled: true,
  32. },
  33. cssLoaderOptions: {
  34. modules: true,
  35. getLocalIdent: (context, localIdentName, localName) => {
  36. if (context.resourcePath.includes('node_modules')) {
  37. return localName;
  38. }
  39. let antdProPath = context.resourcePath.match(/src(.*)/)[1];
  40. if (context.resourcePath.includes('components')) {
  41. antdProPath = antdProPath.replace('components/', '');
  42. }
  43. const arr = antdProPath
  44. .split('/')
  45. .map(a => a.replace(/([A-Z])/g, '-$1'))
  46. .map(a => a.toLowerCase());
  47. arr.pop();
  48. return `antd-pro${arr.join('-')}-${localName}`.replace('--', '-');
  49. },
  50. },
  51. };