-
Notifications
You must be signed in to change notification settings - Fork 12.2k
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
Font Awesome 5 takes a long time to compile with webpacker #12596
Comments
Hi! Thanks for being part of the Font Awesome Community. I'm a RoR developer and I use Heroku ✋ I've done an experiment with webpacker, Rails 5.2 and FA: https://github.com/diowa/ruby2-rails5-bootstrap-heroku Using the configuration you can see in the above repo (pretty standard), this is my compile time:
Compile time without font awesome (branch
The application runs inside a free dyno on heroku-16 stack Note: I'm not using My command line:
Full deploy log
|
@tagliala Thank you so much for chiming in! Can you replace
with
and report the the compilation time? |
@sunnyrjuneja is there a reason why you are including entire styles in your library instead of just the icons that you need? |
@robmadole a use case could be a custom CMS with icon and style selection inside an admin area. In those case, the developer don't know which icons will be used by the final user and should include them all Result from deploy of this branch: https://github.com/diowa/ruby2-rails5-bootstrap-heroku/tree/full-fa
For comparison, here there are the compile times with my MBP 2017 13" i7/16GB/69$adapter master (tree shaking):
without fa:
full fa:
There is a ~12 second difference, so Heroku compile times do not surprise me Please note that I'm not into Node, so tell me what I could test related to rails and webpacker and I will do that |
@robmadole Hey Rob, it's pretty cumbersome to import styles / icons individually and I expected the overhead to be pretty low (cache the js once). Our icon helper looks something like this:
The default style is "regular" but I want to be able to occasionally use light or solid (or may already do so). It's not easy from the method definition to know which styles I'm already using. We currently only use 10 icons from FA. If there was an easy way to import solid, regular and light for each icon, I could manage that. @tagliala My experience with node is also pretty limited. To confirm, is it safe to say that font awesome is now both aware of this and can reproduce this? Just to be clear, it takes 120 seconds with the free version and over 5 minutes with the pro version. @robmadole @tagliala What's a next step? Is there anything I can do to help? |
How long does it take locally on a dev machine? |
@robmadole negligible time on my i7 desktop 16 gb |
I'm not sure what we can do to help. Heroku is a resource-constrained environment. You are loading thousands of icons (that's a lot of JS to churn through). My recommendation would be to not bundle that many icons if you are not using them. I certainly understand your frustration but I can't think of anything else to do in order to help. The JS code for the icon content is really not that crazy. It's just a bunch of names and SVG path data. Would love to help but I'm out of ideas 😸 |
@robmadole I feel frustrated because without FA Pro it takes less than 30 seconds and 512 mb ram holds up the rest of our application just fine. There are two things that would be help me:
Would you be amenable to either of these options? |
Right now our focus is on supporting JavaScript packages and bundlers like webpack and rollup. We might eventually make Rails-specific integrations for our SVG with JS but we'll have to see what the demand is and what benefit it might provide. I think you are assuming that using the asset pipeline would provide performance improvements. Isn't it normally the other way around with JS (webpacker is faster than asset pipeline?)
What version of Webpack are you using? |
@robmadole For whatever reason, the asset pipeline has absolutely no problem chunking through fontawesome-all.js (I downloaded it into vendor/assets/javascripts/fontawesome-all.js and required it in app/assets/javascript/application.js. Maybe it's doing less work?). My entire deployment dropped from over 7 minutes to under 1 minute. I'm fine with this solution but I want to keep my assets in a package management (Gemfile or package.json). If fontawesome-all.js ships in node package (perhaps a folder named dist in the fontawesome package), I can just require it through the asset pipeline since it can see node_modules. It's extremely disappointing to hear that you might not support Rails. I backed the project (wrongfully) assuming that Rails would certainly be a first class citizen. I have been checking https://fontawesome.com/get-started/advanced-options for updates in the gem section, created this issue https://github.com/FortAwesome/Font-Awesome-Pro/issues/980, and 👍 FortAwesome/font-awesome-sass#146. It feels like the opportunity to communicate your stance could have come sooner. I did check the FA Kickstarter and see nothing about Rails so I guess that's my bad.
Webpacker (Rails integration for Webpack) uses Webpack 3 and will be updated to Webpack 4 soon. So, I use Webpack 3 and will be using Webpack 4, soon. I just noticed the Pro CDN is now in beta. I guess I can use that as a solution for now. It also has the added benefit of removing the fontawesome registry dependency from my deployment process. I didn't think much of it until yesterday when it ruined night :(. |
It turns out I can't use the cdn because it doesn't support wildcard subdomains. |
We'll be releasing a new package as part of 5.1.0 that includes all the files that are available via the Pro CDN as an npm package. This should accomplish what you just mentioned.
That's fair.
You might be able to use Code Splitting to write your helper to import all 3 styles with one function call. |
Closing as it hasn't been identified that there is a bug or issue with Font Awesome that is causing this. I will re-open if evidence comes up to the contrary. |
Hi,
I'm a FontAwesome Pro customer and wanted to use Font Awesome in my Ruby on Rails project. No gem was released so I started using webpacker (rails feature to integrate webpack). Font Awesome Pro takes over 6 minutes to compile on Heroku with webpacker. I was able to replicate the same problem with Font Awesome Free (over 2 minutes).
Is it surprising to the maintainers that compiling with webpack takes so long? Here is my reproduction and issue filed with Webpacker. rails/webpacker#1347
The text was updated successfully, but these errors were encountered: