I’m using react-pdf to render a PDF file from a web URL. The app works fine when doing local development, but fails to render when doing a production build. The root of the issue is that the pdf.min.worker.js
file produced by the build has hard-coded file paths in its require
statements that reference the file system of the machine that did the build. For example:
// Note: my local computer account is "administrator"
require("/Users/administrator/code/pdf-test/node_modules/@babel/runtime/helpers/defineProperty.js").default
Obviously, this causes the requires not to be found because they reference development paths in a production build. Does anyone know how to fix this?
Things I’ve tried
- Everything mentioned in this issue and none of them have worked
Code
- I’ve created a small project which demonstrates the issue.