This repository has been archived by the owner on Nov 10, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
79 lines (78 loc) · 1.9 KB
/
webpack.config.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const webpack = require("webpack");
module.exports = {
entry: {
"pdf": "./src/pdf.js",
"svg": "./src/svg.js"
},
target: "web",
module: {
rules: [
// bundle and load afm files verbatim
{
test: /\.afm$/,
type: "asset/source"
},
// convert to base64 and include inline file system binary files used by fontkit and linebreak
{
enforce: "post",
test: /fontkit[/\\]index.js$/,
loader: "transform-loader",
options: {
brfs: {}
}
},
{
enforce: "post",
test: /linebreak[/\\]src[/\\]linebreaker.js/,
loader: "transform-loader",
options: {
brfs: {}
}
}
]
},
devtool: "inline-source-map",
resolve: {
extensions: [".tsx", ".ts", ".js"],
alias: {
// maps fs to a virtual one allowing to register file content dynamically
fs: "pdfkit/js/virtual-fs.js",
// iconv-lite is used to load cid less fonts (not spec compliant)
"iconv-lite": false
},
fallback: {
crypto: false,
stream: require.resolve("readable-stream"),
util: require.resolve("util"),
buffer: require.resolve("buffer"),
zlib: require.resolve("browserify-zlib"),
assert: require.resolve("assert/")
}
},
plugins: [
new webpack.ProvidePlugin({
process: "process/browser",
Buffer: ["buffer", "Buffer"]
}),
new webpack.NormalModuleReplacementPlugin(new RegExp(/\.js$/), function(resource) {
if(resource.context.includes("node_modules") !== true){
resource.request = resource.request.replace(".js", "");
}
})
],
output: {
filename: "[name].js",
path: __dirname + "/lib/",
libraryTarget: "umd",
library: "SwissQRBill"
},
devServer: {
static: {
directory: "./",
},
devMiddleware: {
publicPath: "/lib/"
},
port: 8000
},
};