Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve integration instructions #681

Merged
merged 3 commits into from Mar 16, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Prev

add webpack instructions

  • Loading branch information
Autarc committed Mar 16, 2016
commit cc4f08e9feac2874042d30459e719ad5a832e02c
@@ -188,6 +188,30 @@ There are more examples in the [examples](https://github.com/feross/webtorrent/t
WebTorrent works great with [browserify](http://browserify.org/), an npm module that let's
you use [node](http://nodejs.org/)-style require() to organize your browser code and load modules installed by [npm](https://www.npmjs.com/) (as seen in the previous examples).

##### Webpack

WebTorrent works also great with [webpack](http://webpack.github.io/), a module bundler similar to browserify that supports various files types. Although webpack uses the specified [browser-field](https://github.com/feross/webtorrent/blob/master/package.json#L10) to reference alternative packages for the browser, following configurations have to be done to bundle the code:
```js
{
target: 'web',
node: {
fs: 'empty'
},
module: {
loaders: [
// requires you to install the 'json-loader' module first: npm install --save-dev json-loader
{
test: /\.json$/,
loader: 'json'
}
]
}
}
```
Otherwise you could also directly use the pre-built version via `require('webtorrent/webtorrent.min')`.

#### Global

WebTorrent is also available as a standalone script
([`webtorrent.min.js`](webtorrent.min.js)) which exposes `WebTorrent` on the `window`
object, so it can be used with just a script tag:
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.