首页 > 解决方案 > @蚂蚁设计。为什么所有图标都添加到捆绑包中?

问题描述

我不明白为什么所有图标都在捆绑包中。即使我只使用“antd”中的按钮 import { Button } from 'antd';

webpack-bundle-analyzer.png

如何解决这个问题?

module.exports = {
  presets: ['@babel/preset-react', '@babel/preset-env'],
  plugins: [
    [
      'import',
      {
        libraryName: 'antd',
        libraryDirectory: 'es',
        style: true,
      },
      'antd',
    ],
  ],
};

标签: javascriptnode.jswebpackbabeljsantd

解决方案


推荐阅读