-
Notifications
You must be signed in to change notification settings - Fork 26
/
webpack.config.cjs
82 lines (81 loc) · 1.97 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
75
76
77
78
79
80
81
82
const path = require("node:path");
const LicenseWebpackPlugin = require("license-webpack-plugin").LicenseWebpackPlugin;
const allowedLicenses = [
"MIT",
"BSD-3-Clause"
];
module.exports = {
mode: "production",
devtool: false,
resolve: {
extensions: [".js", ".cjs"],
},
entry: {
"browser-bundle": "./lib/client/browser.cjs"
},
output: {
path: path.resolve(__dirname, "dist"),
filename: "browser-bundle.js"
},
target: ["web", "es5"],
module: {
rules: [
{
test: /\.(m|c)?js$/,
use: {
loader: "babel-loader",
options: {
presets: [
[
"@babel/preset-env",
{
useBuiltIns: "usage", // Add polyfills based on usage in code
corejs: 3,
targets: [
"last 2 iOS major versions",
"last 2 Safari major versions",
"IE 11",
"last 2 Edge versions",
"last 1 Chrome version",
"last 1 ChromeAndroid version",
"last 1 Firefox version",
"Firefox ESR"
]
}
]
],
// Process all files (incl. node_modules)
// except core-js and webpack for which processing is not required
ignore: [
"**/node_modules/core-js/**",
"**/node_modules/webpack/**"
],
// Use "unambiguous" as thirdparty code is unknown
sourceType: "unambiguous"
}
}
}
]
},
plugins: [
new LicenseWebpackPlugin({
addBanner: true,
unacceptableLicenseTest: (licenseType) => {
// Fail when not allowed licenses would be packaged
return !allowedLicenses.includes(licenseType);
},
renderLicenses: (modules) => {
const line = (v) => v ? `\n${v}` : "";
return modules
.sort((a, b) => a.name < b.name ? -1 : 1)
.map((module) => {
let text = `${module.name} (${module.packageJson.version})`;
text += line(module.packageJson.homepage);
text += line(module.licenseId);
text += line(module.licenseText);
return text;
}).join("\n\n");
}
})
]
};