diff --git a/examples/webpack/README.md b/examples/webpack/README.md index 89527803..9966a47f 100644 --- a/examples/webpack/README.md +++ b/examples/webpack/README.md @@ -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 diff --git a/examples/webpack/package.json b/examples/webpack/package.json index 9748f6c9..9ac3cb61 100644 --- a/examples/webpack/package.json +++ b/examples/webpack/package.json @@ -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", diff --git a/examples/webpack/webpack.config.js b/examples/webpack/webpack.config.js index 783be32c..688e0e93 100644 --- a/examples/webpack/webpack.config.js +++ b/examples/webpack/webpack.config.js @@ -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: {