Trying to build from webpack, I'm hitting a lot of dependencies on the node fs module, in js/image/jpeg.js, /js/font/dfont.js, png-js/png-node.js, and several more.
Got it building with these steps.
npm install transform-loader brfs --save
In webpack config module.loaders add
{ test: /pdfkit|png-js/, loader: "transform?brfs" },
{ test: /\.json$/, loader: "json" }
The font examples in the docs don't work because they try to read from the file system. Not sure if this is expected, or if there's a way to embed fonts in the browser bundle, or read from uri instead of file system.
For fonts see https://github.com/devongovett/pdfkit/issues/340.
With the latest create-react-app I've been getting this error:

I'm not even playing with images or font yet. Just trying to get it to load the module..
Any ideas?
edit - (I tried
{ test: /pdfkit|png-js/, loader: "transform?brfs" },
{ test: /\.json$/, loader: "json" }
In webpack 2, I included the following in my webpack.config.js file:
module: {
loaders: {
{ test: /(pdfkit|linebreak|fontkit|unicode|brotli|png-js).*\.js$/, loader: "transform-loader?brfs" }
}
}
This worked, but I'm not sure if it handles everything.
@pboyer Thanks :) You have rescued me
Hi guys,
I use the library in MacOS and Linux with Webpack 1 the way suggested:
loaders: {
{ test: /(pdfkit|linebreak|fontkit|unicode|brotli|png-js).*\.js$/, loader: "transform-loader?brfs" }
}
but the problem persists when trying to pack the project on a Windows 10 machine. Any ideas?
Webpack 1 is not supported anymore.
Here's a example with webpack 4: https://github.com/blikblum/pdfkit-webpack-example
Most helpful comment
Got it building with these steps.
npm install transform-loader brfs --saveIn webpack config
module.loadersaddThe font examples in the docs don't work because they try to read from the file system. Not sure if this is expected, or if there's a way to embed fonts in the browser bundle, or read from uri instead of file system.