-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathwebpack.js
44 lines (42 loc) · 1.68 KB
/
webpack.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* eslint-env node */
const path = require('path');
const CopyPlugin = require("copy-webpack-plugin");
const TerserPlugin = require('terser-webpack-plugin');
const package = require('./package.json');
const versionPdfJs = package.dependencies['pdfjs-dist'];
const versionPdfJsViewer = package.dependencies['pdfjs-dist-viewer-min'];
if (versionPdfJs !== versionPdfJsViewer) {
throw new Error('PDF.js (' + versionPdfJs + ') and the viewer (' + versionPdfJsViewer + ') must use the same versions.');
}
module.exports = {
entry: {
'loader': path.join(__dirname, 'src', 'loader.js'),
'pdfdraw': path.join(__dirname, 'src', 'pdfdraw.js'),
'admin/backend': path.join(__dirname, 'src', 'admin', 'backend.js'),
'pdf.worker': path.join(__dirname, 'node_modules', 'pdfjs-dist', 'build', 'pdf.worker.js'),
},
externals: {
"pdfjs-dist-viewer-min": "window",
"pdfjs-dist": "window",
},
output: {
filename: '[name].js',
path: __dirname + '/js',
},
optimization: {
minimizer: [new TerserPlugin({
extractComments: false,
})],
},
plugins: [
new CopyPlugin({
patterns: [
{ from: "node_modules/pdfjs-dist/cmaps/", to: "../3rdparty/pdfjs/web/cmaps/" },
{ from: "node_modules/pdfjs-dist-viewer-min/build/minified/web/viewer.css", to: "../3rdparty/pdfjs/web/viewer.css" },
{ from: "node_modules/pdfjs-dist-viewer-min/build/minified/web/images/", to: "../3rdparty/pdfjs/web/images/" },
{ from: "node_modules/pdfjs-dist-viewer-min/build/minified/web/locale/", to: "../3rdparty/pdfjs/web/locale/" },
{ from: "node_modules/pdfjs-dist-viewer-min/build/minified/web/pdf.viewer.js", to: "pdf.viewer.js" },
],
}),
],
};