-
Notifications
You must be signed in to change notification settings - Fork 3
/
webpack.config.js
194 lines (185 loc) · 5.13 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
const webpack = require("webpack");
const path = require("path");
const { merge } = require("webpack-merge");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const url = require("url");
const INSPECTORS = [
{
chunkName: "opus",
entry: "./src/inspectors/opus.tsx",
title: "Opus Packet Inspector",
subtitle: `Based off <a href='https://tools.ietf.org/html/rfc6716'>RFC 6716</a>`,
description: "A web-based tool for dissecting Opus codec packets."
},
{
chunkName: "stun",
entry: "./src/inspectors/stun.tsx",
title: "STUN Packet Inspector",
subtitle: `Based off <a href="https://tools.ietf.org/html/rfc5389">RFC 5389</a>`,
description: "A web-based tool for dissecting STUN packets."
},
{
chunkName: "rtp",
entry: "./src/inspectors/rtp.tsx",
title: "RTP Packet Inspector",
subtitle: `Based off <a href="https://tools.ietf.org/html/rfc3550">RFC 3550</a>.`,
description: "A web-based tool for dissecting RTP packets."
},
{
chunkName: "rtcp",
entry: "./src/inspectors/rtcp.tsx",
title: "RTCP Packet Inspector",
description: "A web-based tool for dissecting RTCP compound packets.",
subtitle: ""
},
{
chunkName: "png",
entry: "./src/inspectors/png.tsx",
title: "PNG Format Inspector",
description: "A web-based tool for inspecting PNG chunks.",
subtitle: ""
},
{
chunkName: "ogg",
entry: "./src/inspectors/ogg.tsx",
title: "Ogg Format Inspector",
description: "A web-based tool for inspecting Ogg files.",
subtitle: `Based off <a href="https://tools.ietf.org/html/rfc3533">RFC 3533</a>`
},
{
chunkName: "bmff",
entry: "./src/inspectors/bmff.tsx",
title: "ISO BMFF Format Inspector",
description: "A web-based tool for inspecting ISO BMFF files.",
subtitle: `Based off of ISO standard.`
},
{
chunkName: "ulpfec",
entry: "./src/inspectors/ulpfec.tsx",
title: "ULPFEC Inspector",
description: "A web-based tool for inspecting ulpfec payloads.",
subtitle: `Based off of RFC 5109.`
},
{
chunkName: "riff",
entry: "./src/inspectors/riff.tsx",
title: "RIFF Container Inspector",
description: "A web-based tool for inspecting RIFF container files.",
subtitle: `Based off of Multimedia Programming Interface and Data Specifications 1.0.`
},
{
chunkName: "q3bsp",
entry: "./src/inspectors/q3bsp.tsx",
title: "Quake 3 BSP Inspector",
description: "A web-based tool for inspecting Quake 3 BSP files.",
subtitle: ``
},
{
chunkName: "pak",
entry: "./src/inspectors/pak.tsx",
title: "Quake PAK Inspector",
description: "A web-based tool for inspecting Quake PAK files.",
subtitle: ``
},
{
chunkName: "msgpack",
entry: "./src/inspectors/msgpack.tsx",
title: "Msgpack Inspector",
description: "A web based tool for inspecting msgpack payloads.",
subtitle: `Based off of the <a href='https://github.com/msgpack/msgpack/blob/master/spec.md'>Msgpack Spec</a>`
},
{
chunkName: "binary32",
entry: "./src/inspectors/binary32.tsx",
title: "IEEE 754 Single-Precision Floating Point",
description: "",
subtitle: ``
},
{
chunkName: "glb",
entry: "./src/inspectors/glb.tsx",
title: "GLB Chunk Inspector",
description: "",
subtitle: ``
},
{
chunkName: "custom",
entry: "./src/inspectors/custom.tsx",
title: "Custom Data Inspector",
description: "",
subtitle: ``
}
];
const ENTRIES = {};
const PLUGINS = [];
const GITHUB_ROOT =
"https://github.com/rameshvarun/binary-inspector/blob/master/";
for (let inspector of INSPECTORS) {
ENTRIES[inspector.chunkName] = inspector.entry;
PLUGINS.push(
new HtmlWebpackPlugin({
template: "./src/inspector.html",
filename: inspector.chunkName + "/index.html",
chunks: [inspector.chunkName],
templateParameters: {
title: inspector.title,
subtitle: inspector.subtitle,
description: inspector.description,
githubURL: url.resolve(GITHUB_ROOT, inspector.entry)
}
})
);
}
PLUGINS.push(new CopyPlugin([{ from: "src/index.html", to: "index.html" }]));
const common = {
entry: ENTRIES,
module: {
rules: [
{
test: /\.tsx?$/,
use: "ts-loader",
exclude: /node_modules/
},
{
test: /\.(png|svg|jpg|gif|mp3)$/,
use: ["file-loader"]
},
{
test: /\.css$/i,
use: ["style-loader", "css-loader"]
}
]
},
resolve: {
extensions: [".tsx", ".ts", ".js"]
},
output: {
filename: "[name].js",
path: path.resolve(__dirname, "dist")
},
plugins: PLUGINS,
optimization: {
splitChunks: {
chunks: "all"
}
}
};
const development = {
mode: "development",
devtool: "inline-source-map",
devServer: {
contentBase: "./dist",
https: true
}
};
const production = {
mode: "production"
};
module.exports = env => {
if (env.mode === "development") return merge(common, development);
else if (env.mode === "production") return merge(common, production);
else {
throw new Error(`Unknown environment ${env.mode}.`);
}
};