forked from bpampuch/pdfmake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
99 lines (94 loc) · 2.59 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
var path = require('path');
var StringReplacePlugin = require("string-replace-webpack-plugin");
module.exports = {
entry: './src/browser-extensions/pdfMake.js',
output: {
path: path.join(__dirname, './build'),
filename: 'pdfmake.js',
libraryTarget: 'umd'
},
resolve: {
alias: {
fs: path.join(__dirname, './src/browser-extensions/virtual-fs.js')
}
},
module: {
loaders: [
{test: /\.json$/, loader: 'json'},
{test: /pdfMake.js$/, loader: 'expose?pdfMake', include: [path.join(__dirname, './src/browser-extensions')]},
{test: /pdfkit[\/\\]js[\/\\]mixins[\/\\]fonts.js$/, loader: StringReplacePlugin.replace({
replacements: [
{
pattern: 'return this.font(\'Helvetica\');',
replacement: function () {
return '';
}
}
]})
},
{test: /fontkit[\/\\]index.js$/, loader: StringReplacePlugin.replace({
replacements: [
{
pattern: /fs\./g,
replacement: function () {
return 'require(\'fs\').';
}
}
]})
},
/* temporary bugfix for fontkit version 1.5.2 - issue https://github.com/devongovett/fontkit/issues/65 */
{test: /fontkit[\/\\]index.js$/, loader: StringReplacePlugin.replace({
replacements: [
{
pattern: 'if (i < classDef.classValueArray.length) {',
replacement: function () {
return 'if (i > -1 && i < classDef.classValueArray.length) {';
}
}
]})
},
/* *** */
/* temporary bugfix for fontkit version 1.5.2 - issue https://github.com/devongovett/fontkit/issues/66 */
{test: /fontkit[\/\\]index.js$/, loader: StringReplacePlugin.replace({
replacements: [
{
pattern: 'if (this._font.GDEF) {',
replacement: function () {
return 'if (this._font.GDEF && this._font.GDEF.glyphClassDef) {';
}
}
]})
},
/* *** */
{test: /readable-stream[\/\\]/, loader: StringReplacePlugin.replace({
replacements: [
{
pattern: 'stream.read()',
replacement: function () {
return 'stream.read(9007199254740991)';
}
}
]})
},
/* hack for IE 10 */
{test: /brotli[\/\\]dec[\/\\]/, loader: StringReplacePlugin.replace({
replacements: [
{
pattern: /const /g,
replacement: function () {
return 'var ';
}
}
]})
}
],
postLoaders: [
{test: /fontkit[\/\\]index.js$/, loader: "transform?brfs"},
{test: /unicode-properties[\/\\]index.js$/, loader: "transform?brfs"},
{test: /linebreak[\/\\]src[\/\\]linebreaker.js/, loader: "transform?brfs"}
]
},
plugins: [
new StringReplacePlugin()
]
};