pdfjs-dist bower and gulp concatenation and minification silently fail

738 Views Asked by At

I'm using pdf.js in an angular project. Building with gulp in production mode works fine, but the production build produces non-working code that fails silently without and warnings or errors, whatsoever. I never get a viewer canvas.

1

There are 1 best solutions below

0
On

It turns out the problem lies not with minification, but rather with concatenation. The dist directory of the pdfjs-dist bower package contains three files:

  • pdf.js
  • pdf.worker.js
  • pdf.combined.js

the bower.json file list pdf.js and pdf.worker.js, but when using gulp bower copy and concatenation you should use pdf.combined.js instead of the other two. Add an override to your projects bower.json

"overrides": {
   "pdfjs-dist": {
      "main": [
        "build/pdf.combined.js"
      ]
   }
}