forked from Web3Auth/web3auth-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
29 lines (25 loc) · 883 Bytes
/
webpack.config.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
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
function generateWebpackConfig({ pkg, currentPath, alias, module = {}, pkgBaseConfig = {}, pkgUmdConfig = null }) {
const depsList = Object.keys(pkg.dependencies);
const baseConfig = {
...pkgBaseConfig,
resolve: {
plugins: [new TsconfigPathsPlugin()],
alias: {
...(depsList.includes("bn.js") && { "bn.js": path.resolve(currentPath, "node_modules/bn.js") }),
lodash: path.resolve(__dirname, "node_modules/lodash-es"),
...alias,
},
fallback: {
"bn.js": require.resolve("bn.js"),
},
},
module,
};
const config = { baseConfig };
if (pkgUmdConfig) config.umdConfig = pkgUmdConfig;
return config;
}
module.exports = generateWebpackConfig;