Skip to content
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

Auto Subsetting #37

Open
samjonesigd opened this issue Sep 29, 2023 · 2 comments
Open

Auto Subsetting #37

samjonesigd opened this issue Sep 29, 2023 · 2 comments

Comments

@samjonesigd
Copy link

Could you add a way to make the src directories or files instead of manually adding your icon names?

On a big project this is quite difficult to maintain currently

@omacranger
Copy link
Owner

It's been asked before and I'm hesitant to bake something like this in as I would prefer to keep dependencies & bloat to a minimum. I'll look into some options and see what it may take. I think another package that handles that functionality in the form of a script or Webpack plugin (or both in that package) that parses source files via globs and simply passes them to this package would be preferred.

@callaginn
Copy link

callaginn commented Mar 8, 2024

@samjonesigd I actually took a stab at that a few years ago for our websites. Here's what I came up with:
https://github.com/cremadesign/fontawesome-scraper

It's pretty simple in concept. Basically, it scans target directories for code that references font awesome files and builds out a config for "fontawesome-subset" by pairing egrep with a regular expression: 'fa[A-z]{0,1},? .?fa-[A-z-]+'.

Config basically looks like this:

// Import fontawesome-scraper
import iconScraper from '@cremadesign/fontawesome-scraper';

// Grab icons asynchronously from a list of folders
var icons = await iconScraper({
	folders: [
		'www'
	]
});

// Do something with the final results!
console.log(icons);

And it'll export a "icons.json" file that "fontawesome-subset" can work with:

{
    "solid": [
        "arrow-right",
        "asterisk",
        "ban",
        "exclamation-circle",
        "sync",
        "tools"
    ],
    "brands": [
        "github"
    ],
    "regular": [
        "arrow-left",
        "home",
        "sync"
    ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants