Skip to content

Commit

Permalink
Settings to use with Vite
Browse files Browse the repository at this point in the history
Vite is being used as an alternative to Webpack, and it needs some special settings to get it working with Web3Modal.
Adding this to the documentation will help the users.
Those settings were found thanks to @theurgi at blocknative/web3-onboard#762 (comment)
  • Loading branch information
imsys authored Jan 27, 2022
1 parent 0e91180 commit 50e1ef5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,37 @@ const provider = new ethers.providers.Web3Provider(instance);
const signer = provider.getSigner();
```

## Using with [Vite](https://github.com/vitejs/vite)

```js
//vite.config.js
import nodePolyfills from 'rollup-plugin-polyfill-node';
const production = process.env.NODE_ENV === 'production';

export default {

plugins: [
// ↓ Needed for development mode
!production && nodePolyfills({
include: ['node_modules/**/*.js', new RegExp('node_modules/.vite/.*js')]
})
],

build: {
rollupOptions: {
plugins: [
// ↓ Needed for build
nodePolyfills()
]
},
// ↓ Needed for build if using WalletConnect and other providers
commonjsOptions: {
transformMixedEsModules: true
}
}
}
```

## Using in vanilla JavaScript

You can use the modal from the old fashioned web page JavaScript as well.
Expand Down

0 comments on commit 50e1ef5

Please sign in to comment.