Skip to content

Commit 59c3622

Browse files
committed
Update example app and README.
Fix compatibility with newest BrowserSync and Express.
1 parent 8661a38 commit 59c3622

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ var app = express();
2626

2727
if (app.get('env') == 'development') {
2828
var browserSync = require('browser-sync');
29-
var bs = browserSync.init([], {});
29+
var bs = browserSync({ logSnippet: false });
3030
app.use(require('connect-browser-sync')(bs));
3131
}
3232

33-
app.use(app.router);
34-
3533
// Routes and handlers...
3634
```
3735

@@ -40,9 +38,13 @@ See the [BrowserSync API docs](http://www.browsersync.io/docs/api/) for initiali
4038
## Notes
4139

4240
- The `app.use` statement must come before any handlers that you want to integrate with BrowserSync. This includes dynamic handlers (e.g. `app.use(app.router);`) and static handlers (e.g. `app.use(express.static(__dirname + '/public'));`)
43-
- You must use version 1.0.0 or greater of the `browser-sync` package.
41+
- You must use version 2.0.0 or greater of the `browser-sync` package.
4442
- Injection only happens on responses with a `Content-Type` header of `text/html` and content containing a closing body tag (`</body>`).
4543

44+
## BrowserSync 1.x
45+
46+
If you need to use BrowserSync 1.x, use [version 1.0.2](https://github.com/schmich/connect-browser-sync/releases/tag/v1.0.2) of this package.
47+
4648
## Example
4749

4850
See the [example](example) folder.

example/app.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,16 @@ var app = express();
55

66
app.set('views', __dirname);
77
app.set('view engine', 'ejs');
8-
app.use(express.logger('dev'));
98

109
if (app.get('env') == 'development') {
1110
var browserSync = require('browser-sync');
12-
var bs = browserSync.init([], { debugInfo: false });
11+
var bs = browserSync({ logSnippet: false });
1312
app.use(require('connect-browser-sync')(bs));
1413
}
1514

16-
app.use(app.router);
17-
1815
app.get('/', routes.index);
1916

20-
http.createServer(app).listen(3000, function() {
21-
console.log('Listening...');
17+
var port = 3000;
18+
http.createServer(app).listen(port, function() {
19+
console.log('Listening on port ' + port + '...');
2220
});

example/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"ejs": "*"
1111
},
1212
"devDependencies": {
13-
"browser-sync": "*",
14-
"connect-browser-sync": "*"
13+
"browser-sync": ">=2.0.0",
14+
"connect-browser-sync": ">=2.0.0"
1515
}
1616
}

0 commit comments

Comments
 (0)