Skip to content

Commit

Permalink
Fix webpack config, app is now functional
Browse files Browse the repository at this point in the history
  • Loading branch information
mainnet-pat authored Sep 1, 2024
1 parent 311e65f commit 445d7fa
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion config-overrides.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
const webpack = require("webpack");
const fs = require("fs");

fs.mkdirSync("public", { recursive: true });
[
{
src: "node_modules/monero-ts/dist/monero_wallet_keys.wasm",
dest: "public/monero_wallet_keys.wasm",
},
{
src: "node_modules/monero-ts/dist/monero_wallet_full.wasm",
dest: "public/monero_wallet_full.wasm",
},
{
src: "node_modules/monero-ts/dist/monero_web_worker.js",
dest: "public/monero_web_worker.js",
},
].forEach(({ src, dest }) => fs.copyFileSync(src, dest))

module.exports = function override(config) {
const fallback = config.resolve.fallback || {};
Expand Down Expand Up @@ -32,9 +49,24 @@ module.exports = function override(config) {
fullySpecified: false,
},
});
const fileLoaderRule = getFileLoaderRule(config.module.rules);
fileLoaderRule.exclude.push(/\.cjs$/);
config.externals = {
...config.externals,
child_process: 'child_process'
};
return config;
};
};

function getFileLoaderRule(rules) {
for(const rule of rules) {
if("oneOf" in rule) {
const found = getFileLoaderRule(rule.oneOf);
if(found) {
return found;
}
} else if(rule.test === undefined && rule.type === 'asset/resource') {
return rule;
}
}
}

0 comments on commit 445d7fa

Please sign in to comment.