Best practice for NPM scripts in a theme?

So, the specific situation I’m in is regarding fonts, but this is likely to be applicable more widely.

I am building a custom theme for a client with specific brand requirements around fonts etc. This particular font will be part of the theme I’m building. Currently I include the OTF font in the theme’s assets folder, and use an npm build script to convert that to the various different formats.

My preference would be to use hugo pipelines for this, but my understanding is that it’s not possible to define custom pipelines.

So, i think my question is really around best practices for doing this. cd-ing into the theme and running npm build isn’t the end of the world, but ideally this is something I could make run before hugo builds the site.

If the font is not changing constantly, you could convert it once into the required format(s). Is anything but woff2 really a thing today?

Cheers. The source file is OTF but I guess i could just convert it and commit the converted files in this instance. However, there are other situations in which it might be helpful to programmatically generate assets with a script.

Another site I am in the process of converting to hugo has a custom icon font. Folder of svg files that are converted into an icon font at build time. I would rather not commit the generated font every time an icon is added.

If you treat your theme as a separate component, usually more stable than the site content,
you could build a release version of the theme (with the npm, …), provide that as a hugo module, git submodule or just a release artifact or release-repo/branch.

with modules you could use replace or a workspace while developing. see Use Hugo Modules

may also be practical for the icon font. which would allow for separate versioning if icons are added or removed.

but that all adds some complexity