Open JonHaywood opened 2 years ago
One thing I noticed is that when you import font-awesome like this:
import { faQuestionSquare } from '@fortawesome/pro-solid-svg-icons';
all fonts from the package are inlined in the sourcemaps (+10mb of inlined SVG). This was happening both in my normal builds and storybook builds
Try adding this
devtool: null
to your storybook webpack config in main.js
to completely disable sourcemaps and see if it improves.
I haven't figured out how to disable sourcemaps for font-awesome only in storybook builds though. Adding this to plugins work on my normal builds but not in storybook:
new EvalSourceMapDevToolPlugin({
filename: '[file].map[query]',
exclude: [/fortawesome/i],
module: true,
columns: false,
}),
for now I just live with it in storybook
Describe the bug
When a story imports a component that uses the FontAwesome npm package, build time skyrockets. On my local machine it takes around 20 minutes for my entire project, but over an hour on my build server.
I'm using React and MDX stories. I can reproduce the 20 minute build consistently with all the files in my project. But I can also reproduce it when I have just one MDX story, given that story imports a component that uses FontAwesome. In the case of only that one MDX story, the build takes 10 minutes on my machine. The issue disappears immediately if I create one MDX story which doesn't reference FontAwesome. In that case the build is under 60 seconds.
Example MDX story that can repro the issue:
Example component:
Important note: I have FontAwesome (pro and free) installed locally. So the build is not hitting the live npm servers. I have a yarn workspace set up with all the FontAwesome packages in the
/vendor
directory.I suspect the root cause of the issue isn't anything special about FontAwesome but the sheer number of files on disk in those packages. FontAwesome has tens of thousands of files included across all its packages. However, this isn't a problem for my rollup build, it completes just fine and pretty quick. So there's something about the Storybook webpack build that's getting hitched up. I'm hoping there's some config flag I can tweak in
main.js
that can speed this up, or tell it to exclude a folder, or something.Here's
main.js
:To Reproduce
Edit: I was able to repro this with the free versions of FontAwesome. Repository here: https://github.com/JonHaywood/storybook-fontawesome-repro
The build times aren't as dramatic but still significant. Building with just one story that references FontAwesome takes 2 minutes reliably on my machine. Removing that story takes it down to 22 seconds.
System