Skip to content

Commit

Permalink
Added docs about webpack config
Browse files Browse the repository at this point in the history
This commit provides a webpack config for a bundle similiar to browserify.

Browserify bundles to an empty function for `fs`, and for each module declares
`fs` as a `graceful-fs` require.

https://benclinkinbeard.com/posts/how-browserify-works/

The webpack bundle built from this commit's config resolves `graceful-fs`
as an alias to `fs`.

`fs` used in dat-sdk/index for browser/hyperdrive IO:

https://github.com/random-access-storage/random-access-web
  • Loading branch information
urgentest committed Feb 6, 2020
1 parent d52d845 commit ee0c92a
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,29 @@ trie.put('key', 'value', () => {

```

## Examples (webpack.config.js)

To bundle with webpack instead of browserify, resolve the `fs` module with the `graceful-fs` module.

```js
const path = require('path')

module.exports = {
entry: './src/dat.js',
target: 'web',
resolve: {
alias: {
fs: 'graceful-fs'
}
},
output: {
filename: 'dat.js',
path: path.resolve(__dirname, 'dist')
}
}

```

## API (Promise)

### `const {DatArchive, destroy} = SDK({ storageOpts, swarmOpts, driveOpts, coreOpts, dnsOpts })`
Expand Down

0 comments on commit ee0c92a

Please sign in to comment.