[Vuejs]-Import custom worker into component vuejs with webpack dev-server (vue-cli-service)

0πŸ‘

βœ…

I tried lot of things but it seems that webpack bring forth many others technicals concepts which increase difficult to understand and correctly import worker. Perhaps it exists other solution into webpack config file but I don’t found.

For now the single solution have found is this :

  • copy the worker module (pdfjs-dist) into the node_modules directory to the public directory of your app for respect structure directory
  • declare path directly to this public directory and target your worker file (pdf.worker.js)

Those result this code line :

pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdfjs/build/pdf.worker.js'

enter image description here

Leave a comment