Skip to content

Commit

Permalink
No longer need to swap fetcher.js and fetcher.client.js manually via …
Browse files Browse the repository at this point in the history
…webpack
  • Loading branch information
Rajiv Tirumalareddy committed Sep 3, 2014
1 parent f0b071f commit c046b61
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 22 deletions.
15 changes: 0 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,21 +137,6 @@ var fetchr = require('fetchr'),
//...
```


## 5. Swap Fetchr <=> Fetchr.client

Fetchr relies on a build process that swaps out `lib/fetchr.js` with `lib/fetchr.client.js` in the bundle that is generated for client side use. Usually the bundle is generated using tools like [webpack](http://webpack.github.io/) or [browserify](http://browserify.org/).

```
//webpack config
plugins: [
//...
//Replace fetcher lib with client side fetcher lib
new webpack.NormalModuleReplacementPlugin(/^fetchr$/, require.resolve('fetchr/libs/fetcher.client.js'))
//...
]
```

# Usage Examples

See the [simple example](https://github.com/yahoo/fetchr/tree/master/examples/simple)
Expand Down
8 changes: 1 addition & 7 deletions examples/simple/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@
* Copyright 2014, Yahoo! Inc.
* Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
*/
var webpack = require('webpack'),
path = require('path');
module.exports = {
entry: require.resolve('./client/app.js'),
output: {
path: __dirname+'/client/build/',
filename: "app.js"
},
plugins: [
//Replace fetcher lib with client side fetcher lib
new webpack.NormalModuleReplacementPlugin(/^..\/..\/..\/libs\/fetcher.js$/, path.resolve('../../libs/fetcher.client.js'))
]
}
};
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"mockery": "^1.4.0",
"precommit-hook": "^1.0.2"
},
"browser": {
"./libs/fetcher.js": "./libs/fetcher.client.js"
},
"jshintConfig": {
"node": true
},
Expand Down

0 comments on commit c046b61

Please sign in to comment.