Simple example of using PdfKit with webpack
- Minimal webpack 5 setup
- Automatically register binary files added to static-assets folder
- Register AFM fonts provided by pdfkit
- Shows how to load and register files lazily
- add alias to map
fs
calls to pdfkit virtual file system implementation - ignore crypto package to save bundle file size
- add aliases to native node packages (buffer, stream, zlib, util, assert)
- configure
*.afm
files to be imported as text - configure all files in
src/static-assets
folder to be imported encoded as base64 - configure all files in
src/lazy-assets
folder to be imported as URLs - convert binary files used by linebreak and fontkit to base64
The strategy to register binary files and AFM fonts inlines them in source code, increasing the bundle size significantly