Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5ebeb1b

Browse files
committed
- Improved client-side bundling chapter
1 parent d6889ee commit 5ebeb1b

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,28 @@ Since rewire relies heavily on node's require mechanism it can't be used on the
116116
###browserify
117117

118118
```javascript
119-
var b = browserify();
119+
var b = browserify(),
120+
bundleSrc;
121+
122+
// Add rewire as browserify middleware
123+
// @see https://github.com/substack/node-browserify/blob/master/doc/methods.markdown#busefn
120124
b.use(require("rewire").bundlers.browserify);
125+
126+
b.addEntry("entry.js");
127+
bundleSrc = b.bundle();
121128
```
122129

123130
###webpack
124131

125132
```javascript
126-
var options = {};
133+
var webpackOptions = {
134+
output: "bundle.js"
135+
};
136+
137+
// This function modifies the webpack options object.
138+
// It adds a postLoader and postProcessor to the bundling process.
139+
// @see https://github.com/webpack/webpack#programmatically-usage
140+
require("rewire").bundlers.webpack(webpackOptions);
127141

128-
require("rewire").bundlers.webpack(options);
142+
webpack("entry.js", webpackOptions, function () {});
129143
```

0 commit comments

Comments
 (0)