generated from CMU-313/NodeBB-S24
-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.common.js
85 lines (80 loc) · 2.53 KB
/
webpack.common.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
"use strict";
const path = require("path");
const url = require("url");
const nconf = require("nconf");
const activePlugins = require("./build/active_plugins.json");
let relativePath = nconf.get("relative_path");
if (relativePath === undefined) {
nconf.file({
file: path.resolve(
__dirname,
nconf.any(["config", "CONFIG"]) || "config.json",
),
});
const urlObject = url.parse(nconf.get("url"));
relativePath =
urlObject.pathname !== "/"
? urlObject.pathname.replace(/\/+$/, "")
: "";
}
module.exports = {
plugins: [],
entry: {
nodebb: "./build/public/src/client.js",
admin: "./build/public/src/admin/admin.js",
},
output: {
filename: "[name].min.js",
chunkFilename: "[name].[contenthash].min.js",
path: path.resolve(__dirname, "build/public"),
publicPath: `${relativePath}/assets/`,
clean: {
keep(asset) {
return (
asset === "installer.min.js" || !asset.endsWith(".min.js")
);
},
},
},
watchOptions: {
poll: 500,
aggregateTimeout: 250,
},
resolve: {
symlinks: false,
modules: [
"build/public/src/modules",
"build/public/src",
"node_modules",
...activePlugins.map((p) => `node_modules/${p}/node_modules`),
],
extensions: [".js", ".json", ".wasm", ".mjs"],
alias: {
assets: path.resolve(__dirname, "build/public"),
forum: path.resolve(__dirname, "build/public/src/client"),
admin: path.resolve(__dirname, "build/public/src/admin"),
vendor: path.resolve(__dirname, "public/vendor"),
benchpress: path.resolve(__dirname, "node_modules/benchpressjs"),
Chart: path.resolve(__dirname, "node_modules/chart.js"),
Sortable: path.resolve(__dirname, "node_modules/sortablejs"),
cropper: path.resolve(__dirname, "node_modules/cropperjs"),
"jquery-ui/widgets": path.resolve(
__dirname,
"node_modules/jquery-ui/ui/widgets",
),
"ace/ace": path.resolve(
__dirname,
"build/public/src/modules/ace-editor.js",
),
},
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
exclude: /node_modules/,
loader: "ignore-loader",
},
],
},
};