babel.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. module.exports = {
  2. ignore: [
  3. /[\\\/]core-js/,
  4. /webpack[\\\/]buildin/
  5. ],
  6. overrides: [{
  7. test: "./node_modules",
  8. }],
  9. sourceType: "unambiguous",
  10. presets: [
  11. [
  12. '@babel/preset-env',
  13. {
  14. modules: false,
  15. useBuiltIns: 'usage',
  16. corejs: {
  17. version: 3,
  18. proposals: true
  19. },
  20. targets: {
  21. "chrome": 58,
  22. "ie": 11
  23. }
  24. }
  25. ],
  26. '@babel/preset-react',
  27. '@babel/preset-typescript'
  28. ],
  29. plugins: [
  30. 'react-hot-loader/babel',
  31. '@babel/plugin-proposal-class-properties',
  32. '@babel/plugin-syntax-dynamic-import',
  33. '@babel/plugin-proposal-optional-chaining',
  34. ["import", {
  35. "libraryName": "antd",
  36. "libraryDirectory": "es",
  37. "style": true
  38. }],
  39. ["transform-imports", {
  40. "react-router": {
  41. "transform": "react-router/${member}",
  42. "preventFullImport": true
  43. },
  44. "lodash": {
  45. "transform": "lodash/${member}",
  46. "preventFullImport": true
  47. }
  48. }]
  49. ],
  50. env: {
  51. production: {
  52. only: ['app', 'libs', 'share'],
  53. plugins: [
  54. 'lodash',
  55. 'transform-react-remove-prop-types',
  56. // '@babel/plugin-transform-react-inline-elements',
  57. '@babel/plugin-transform-react-constant-elements'
  58. ]
  59. },
  60. test: {
  61. plugins: [
  62. '@babel/plugin-transform-modules-commonjs',
  63. 'dynamic-import-node'
  64. ]
  65. }
  66. }
  67. }