omacranger / fontawesome-subset

Creates subsets of FontAwesome fonts for optimized use on the web.
GNU General Public License v3.0
66 stars 15 forks source link

Improve feedback in case pro is not configured in options #30

Closed krichter722 closed 2 years ago

krichter722 commented 2 years ago

I just got started using your awesome tool and simply tried to get

import { fontawesomeSubset } from "fontawesome-subset";

fontawesomeSubset(
    ["check", "square", "caret-up"],
    "sass/webfonts"
)

working. I installed FontAwesome Pro follolwing the instructions and got the feedback

Unable to find either the Free or Pro FontAwesome files in node_modules folder. Double-check that you have your preferred fontawesome package as a dependency in `package.json` and rerun the installation.

This is a bit confusing because it seems that if options are omitted the fallback is free and the FontAwesome Free installation is not found while the Pro installation is present and correct. Adding

{ package: "pro" }

Afaik the feedback could be improved by pointing out that using pro requires the package property set. My proposal:

Unable to find either the Free or Pro FontAwesome files in node_modules folder. Double-check that you have your preferred fontawesome package as a dependency in `package.json` and rerun the installation. You need to specify `package: "pro"` in `fontawesomeSubset` arguments in case you're using FontAwesome Pro.

Or maybe that's not how it's supposed to work and there's a bug in the auto-detection of free/pro or you want to implement such a detection right away.

experienced with 4.3.0

omacranger commented 2 years ago

Hello! Thanks for the feedback. I agree that there could be some improvement to that notice / message. Let me see what I can do to improve it / make it more clear that the requested package is missing (instead of both not being found which the wording currently implies).

omacranger commented 2 years ago

Does this make it a bit more clear as the console error?

Unable to resolve the module '@fortawesome/fontawesome-{PASSED_PACKAGE_TYPE}'. Double-check that you have your preferred fontawesome package installed as a dependency and the package type passed into the options if using Pro features.

fontawesomeSubset(..., ..., { package: 'pro' })

krichter722 commented 2 years ago

@omacranger I think so, thank you!

omacranger commented 2 years ago

Closed by 934c9353e0e9a7544c8f815ae31e1542c4fed02f / 4.3.1