Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
61 lines (58 loc) · 1.4 KB
/
Copy pathwebpack.config.js
File metadata and controls
61 lines (58 loc) · 1.4 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
60
61
const path = require("node:path");
const shared = {
mode: "production",
devtool: false,
target: ["web", "es2018"],
entry: "./src/index.ts",
resolve: { extensions: [".ts", ".js"] },
module: {
rules: [{ test: /\.ts$/, loader: "ts-loader", options: { transpileOnly: true } }]
}
};
const modernEntries = Object.fromEntries([
"common", "common-phrases", "full", "full-phrases", "common-search", "full-search"
].map(name => [name, `./src/modern/${name}.ts`]));
module.exports = [
{
...shared,
name: "umd",
output: {
path: path.resolve(__dirname, "dist"),
filename: "pyfl.min.js",
libraryTarget: "umd",
umdNamedDefine: true,
globalObject: "(typeof self !== 'undefined' ? self : this)"
}
},
{
...shared,
name: "esm",
experiments: { outputModule: true },
output: {
path: path.resolve(__dirname, "dist"),
filename: "index.mjs",
library: { type: "module" }
}
},
{
...shared,
name: "modern-cjs",
entry: modernEntries,
output: {
path: path.resolve(__dirname, "dist/modern"),
filename: "[name].cjs",
library: { type: "commonjs2" }
}
},
{
...shared,
name: "modern-esm",
entry: modernEntries,
experiments: { outputModule: true },
output: {
path: path.resolve(__dirname, "dist/modern"),
filename: "[name].mjs",
library: { type: "module" }
}
}
];