-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Any way to reduce bundle size after tree shaking? #10
Comments
It seems more people have reported this in the Font-Awesome repo: FortAwesome/Font-Awesome#16005 I dont see anything necessarily wrong at least on our side |
@pimlie The problem is fortawesome repo root index files are using old modules so doing import from root iconsets imports the whole set even if you write partial imports (since old modules work like that) A workaround is using the way old import { faBars } from '@fortawesome/free-solid-svg-icons'; // imports whole set doing this would allow the size to reduce: import { faBars } from '@fortawesome/free-solid-svg-icons/faBars.js'; // imports only file itself |
Are you suggesting to avoid pulling icons inside |
What I am suggesting is having separate imports that use icon files instead of importing them from module root. That was how old version of the module did it. |
@fmakdemir Tree-shaking should be working afaik, we have a test for that: https://github.com/nuxt-community/fontawesome-module/blob/master/test/module.test.js#L25 |
From my experiments on a live environment it didn't work as intended. Is it possible that the issue is with webpack? We are using |
Could you please share your fontawesome config from nuext.confg and a bundle analyzer screenshot? |
Tree shaking is disabled in dev, so it imports the whole set in development. |
Note you can use babel-plugin-transform-imports lib to this automatically for you on build:
Edit: my extracted example above includes handling of tree shaking for lodash so you can just remove that if you don't use it |
After correctly using tree shaking (I'm using about 20 icons, no layers) and setting:
in module config, my top size in bundle is fontawesome-svg-core which includes some unuseful code for my needs and it seems there's no way to limit its size. Am I missing something? thanks
The text was updated successfully, but these errors were encountered: