forked from Web3Auth/web3auth-wagmi-connector
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
43 lines (36 loc) · 1.03 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path");
const TsconfigPathsPlugin = require("tsconfig-paths-webpack-plugin");
function generateWebpackConfig({ pkg, currentPath, alias, module = {}, ssrModule = null, pkgBaseConfig = {} }) {
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"),
},
},
};
const config = { baseConfig };
config.umdConfig = {
module,
};
config.cjsConfig = {
module: ssrModule || module,
};
return config;
}
const pkg = require("./package.json");
const currentPath = path.resolve(".");
const config = generateWebpackConfig({
currentPath,
pkg,
alias: {},
});
module.exports = config;