Integrating a font with webpack without an html


I’m making a game with Babylonjs which is then compiled with webpack to generate a single JS file at the end (game build). My problem is that I’d like to integrate a font into my game, but at the end I don’t have an html file to link to a font. How can I do this?



This really looks like a @RaananW question :slight_smile:

Just to clarify thing a bit too: are you using this font with HTML only or in Babylon GUI too?

I’m using the Babylon GUI too (the idea is to set a specific font for a textBlock).

so what do you have ? You can just have a single js file , what is loading the js file ?

Currently, I have a platform with several mini games. Each game contains its own distinct elements. A game is represented by a package in its own right.

There must be some index.html either generated or created by you.
The Babylon GUI is taking font name that was already loaded to the DOM (and correct me if I am wrong, of course :-))

So your best course of action:

  1. (a prestep FTW!) decide whether you want the font to be served in some CDN or as part of your app
  2. create a CSS file loading the font file. Either load from a local file or from the CDN
  3. Let webpack process this CSS. Webpack’s CSS loader will take care of bundling the local font for you.
  4. ???
  5. Profit!