Problem: Common antd components (such as Button) are being duplicated across multiple chunks, instead of being extracted into a separate file, and thus being downloaded more than once by the end user.
I'm using create-react-app in conjunction with react-app-rewired and it's injectBabelPlugin function to modularly call Ant Design components.
My config-overrides.js
const { injectBabelPlugin } = require("react-app-rewired")
module.exports = function override(config, env) {
return injectBabelPlugin(["import", { libraryName: "antd", style:
"css" }], config)
}
and I call the components like:
import { Row, Col, Button } from "antd"
This all works fine and dandy.
The issue i'm having is when running webpack-bundle-analyzer, i'm seeing that common antd components (such as Button) are being duplicated across multiple chunks.
I've tried some CommonChunksPlugin configurations but to no avail.
My end goal is to load antd components, that are used in multiple chunks, in their own file. Is this possible using code splitting and lazy loaded components?