Munter / subfont

Command line tool to optimize your webfont loading. Aggressive subsetting based on your font use, self-hosting of Google fonts and preloading
MIT License
1.56k stars 29 forks source link

Parcel v2 Optimizer Plugin #78

Open s0kil opened 4 years ago

s0kil commented 4 years ago

I was wondering if subfont could have an optimer plugin for Parcel v2?

s0kil commented 4 years ago

Instead of having to run a Parcel build step, and then subfont, it will be done in one go.

papandreou commented 4 years ago

I'm not super familiar with the api that Parcel exposes to plugins, but it's probably possible. Might require a heavy restructuring of subfont itself to make it less dependent on assetgraph, which I'm not sure that we want.

Munter commented 4 years ago

A bundler for parcel would be more correct in terms of its lifecycle.

It would be completely possible to build this, but it would probably not be a whole lot faster unless we accidentally have the same AST abstraction in Parcel and Assetgraph so we could skip the heavy parsing work. I can see they use postcss as well, but the dom representation differs.

I imagine you could build such a plugin, iterate through all the html, css and font assets on the parcel graph and manually feed them into assetgraph to get our representation, then run something like https://github.com/parcel-bundler/parcel#bundler on it and load all the updated and added assets back into the parcel graph

I also see this as seperate project, that just happens to use subfont. Like https://github.com/Munter/netlify-plugin-subfont