I use Storybook with CRA preset in my project and run Storybook locally. I would like to use namespace imports in my storybook for better developer experience:
// this is more convenient
import { ArrowForward, Star } from '@material-ui/icons';
// than this
import ArrowForward from '@material-ui/icons/ArrowForward'
import Star from '@material-ui/icons/Star'
It seems to be tree-shaking correctly during the build process - both approaches yield the same bundle size.
However when running storybook locally via yarn storybook
, importing from the aggregate namespace:
import { ArrowForward, Star } from '@material-ui/icons'
results in approximately 20 seconds longer build time.
I tried using both tree-shaking plugins from material ui guide with the suggested config inside projectRoot/.storybook.babelrc.js
, but with no luck.
It sure processes the .babelrc.js
, since invalid syntax there breaks the build. However it still loads all the icons.
Is it possible to get it working within a CRA?