I need to use PDF.js with Webpack, I have done the documentation that says adding an entry for pdf.worker.
Here is the record and output of my webpack configuration:
entry: { index: './src/client/home/home.jsx', 'pdf.worker': 'pdfjs-dist/build/pdf.worker.entry' }, output: { path: path.join(__dirname, 'build/client'), publicPath: '/', filename: [name]-[chunkhash].js, }
And yet according to the documentation, in javacript code I need to specify the working path as follows:
pdfjsLib.PDFJS.workerSrc = '/pdf.worker.bundle.js';
The problem is that I use chunkhash to generate the file, so it cannot find the pdf.worker.bundle.js file.
I see two solutions:
Delete the hash for the worker ONLY in webpack: [name] -bundle.js But how can I tell webpack ONLY to do this for the worker, and not for other .js files?
Change pdfjsLib.PDFJS.workerSrc value after generating the code, how can I do this?
Also, may I think that the first solution is not so good, since the user will always cache the same employee?
source share