-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.cjs
76 lines (66 loc) · 1.71 KB
/
webpack.config.cjs
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
/*eslint-env node */
const path = require("path");
const webpack = require("webpack");
const TerserPlugin = require("terser-webpack-plugin");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
const BANNER_TEXT = `'[name].js is part of the ArchiveWeb.page system (https://archiveweb.page) Copyright (C) 2020-${new Date().getFullYear()}, Webrecorder Software. Licensed under the Affero General Public License v3.'`;
module.exports = (env, argv) => {
return {
target: "web",
entry: {
"main": "./src/index.ts",
},
output: {
filename: "index.js",
globalObject: "self",
library: {
type: "module"
}
},
experiments: {
outputModule: true
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
extractComments: false,
}),
]
},
resolve: {
extensions: [".ts", ".js"],
plugins: [new TsconfigPathsPlugin()],
},
devtool: argv.mode === "production" ? undefined : "source-map",
plugins: [
new webpack.NormalModuleReplacementPlugin(
/^node:*/,
(resource) => {
switch (resource.request) {
case "node:stream":
resource.request = "stream-browserify";
break;
}
},
),
new webpack.BannerPlugin(BANNER_TEXT),
],
module: {
rules: [
{
test: /wombat.js|wombatWorkers.js|index.html$/i,
use: ["raw-loader"],
},
{
test: /\.tsx?$/,
loader: "ts-loader",
include: path.resolve(__dirname, "src"),
options: {
onlyCompileBundledFiles: false,
},
},
],
},
};
}