amaryfilo / connect-wallet

Connect Crypto Wallet by using CoinbaseWallet (WalletLink), KardiaChain, MetaMask browser extentions or mobile application and WalletConnect service by scanning Wallet Qr-code.
MIT License
19 stars 11 forks source link

Issues with webpack >= 5 #12

Open remi-blaise opened 1 year ago

remi-blaise commented 1 year ago

Hello,

There are issues at install for using polyfill in the browser with webpack > 5

image image

Also installing @coinbase/wallet-sdk which had to be done manually.

Thanks for the work.

Take care,

remi-blaise commented 1 year ago

fixed it with craco.config.js

const webpack = require('webpack')

module.exports = {
  webpack: {
    plugins: {
      add: [
        // Work around for Buffer is undefined:
        // https://github.com/webpack/changelog-v5/issues/10
        new webpack.ProvidePlugin({
          Buffer: ['buffer', 'Buffer'],
        }),
      ],
    },

    configure: (webpackConfig, { env, paths }) => {
      // eslint-disable-next-line no-param-reassign
      webpackConfig.resolve.fallback = {
        "crypto": require.resolve("crypto-browserify"),
        "stream": require.resolve("stream-browserify"),
        "assert": require.resolve("assert"),
        "http": require.resolve("stream-http"),
        "https": require.resolve("https-browserify"),
        "os": require.resolve("os-browserify"),
        "url": require.resolve("url"),
        "buffer": require.resolve("buffer"),
      };
      return webpackConfig;
    },
  },
};