Skip to content

Commit

Permalink
Add missing dependencies to webpack example
Browse files Browse the repository at this point in the history
  • Loading branch information
blikblum committed Aug 3, 2021
1 parent 29216b7 commit 55ed6d5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
16 changes: 14 additions & 2 deletions examples/webpack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ Simple example of using PdfKit with webpack
- Register AFM fonts provided by pdfkit
- Shows how to load and register files lazily

### Remarks
### Technical details

Refer to webpack.config.js to details about configuration
[`webpack.config.js`](webpack.config.js)

- add alias to map `fs` calls to pdfkit virtual file system [implementation](../../lib/virtual-fs.js)
- ignore iconv-lite and crypto packages 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

### Caveats

The strategy to register binary files and AFM fonts inlines them in source code, increasing the bundle size significantly
5 changes: 4 additions & 1 deletion examples/webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"license": "MIT",
"dependencies": {
"assert": "^2.0.0",
"brace": "^0.11.1",
"browserify-zlib": "^0.2.0",
"buffer": "^6.0.3",
"pdfkit": "^0.12.3",
"process": "^0.11.10",
"readable-stream": "^3.6.0"
"readable-stream": "^3.6.0",
"util": "^0.12.4"
},
"devDependencies": {
"brfs": "^2.0.2",
Expand Down
4 changes: 3 additions & 1 deletion examples/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ module.exports = {
// fallbacks for native node libraries
buffer: require.resolve('buffer/'),
stream: require.resolve('readable-stream'),
zlib: require.resolve('browserify-zlib')
zlib: require.resolve('browserify-zlib'),
util: require.resolve('util/'),
assert: require.resolve('assert/')
}
},
module: {
Expand Down

0 comments on commit 55ed6d5

Please sign in to comment.