This repository was archived by the owner on Nov 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathwebpack.config.js
More file actions
59 lines (53 loc) · 1.35 KB
/
webpack.config.js
File metadata and controls
59 lines (53 loc) · 1.35 KB
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
// Using require because this file uses module.exports
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require("fs");
function findEntrypoints(subdirectory) {
const entrynames = fs.readdirSync(`./public/assets/ts/${subdirectory}`);
let results = [];
for (const entryname of entrynames) {
if (entryname.includes(".md")) {
continue;
} else if (entryname.includes(".ts")) {
results.push(`${subdirectory}${entryname}`.replace(/\.ts$/, ""));
} else {
results = results.concat(findEntrypoints(`${subdirectory}${entryname}/`));
}
}
return results;
}
const entrypoints = findEntrypoints("").reduce((map, currentPath) => {
map[
`./public/assets/js/${currentPath}` // output path
] = `./public/assets/ts/${currentPath}`; // source file path
return map;
}, {});
module.exports = {
devtool: "source-map",
entry: entrypoints,
output: {
filename: "[name].js",
path: __dirname,
},
mode: "development",
module: {
rules: [
{
test: /\.[jt]sx?$/,
use: [
{
loader: "ts-loader",
options: {
compilerOptions: {
sourceMap: true,
},
},
},
],
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js", ".json"],
},
};