Skip to content

Commit

Permalink
show connection status, update to webpack(-dev-middleware) 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
sokra committed Nov 9, 2012
1 parent d0fbc08 commit 83d9909
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,18 @@ Options:
``` javascript
var Server = require("webpack-dev-server");
var options = {
content: absoluteFilenameToContentHtmlPage, // it will default to a simple page
contentUrl: "http://...", // it will default to undefined
content: absoluteFilenameToContentHtmlPage,
// Content page to display
// it will default to a simple page

contentUrl: "http://...",
// if set it will load this URL as content page
// it will default to undefined

middleware: {
// webpack-dev-middleware options
},

webpack: {
// webpack options
// ...
Expand Down
21 changes: 18 additions & 3 deletions client/live.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ $(function() {

io.on("ok", function() {
okness.text("");
$errors.hide(); iframe.show();
$errors.hide();
reloadApp();
});

io.on("warnings", function(warnings) {
okness.text("Warnings while compiling.");
$errors.hide(); iframe.show();
$errors.hide();
reloadApp();
});

Expand All @@ -41,15 +41,30 @@ $(function() {
$errors.show(); iframe.hide();
});

io.on("disconnect", function() {
status.text("");
okness.text("Disconnected.");
$errors.text("\n\n\n Lost connection to webpack-dev-server.\n Please restart the server to reestablish connection...\n\n\n\n");
body.css({background: ""});
$errors.show(); iframe.hide();
});

iframe.load(function() {
status.text("App ready.");
body.css({background: ""});
iframe.show();
});

function reloadApp() {
status.text("App updated. Reloading app...");
body.css({background: "red"});
iframe.attr("src", "/content.html");
try {
var old = $("#iframe")[0].contentWindow.location + "";
if(old.indexOf("about") == 0) old = null;
iframe.attr("src", old || "/content.html");
} catch(e) {
iframe.attr("src", "/content.html");
}
}

});
4 changes: 3 additions & 1 deletion lib/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ function Server(entry, options) {
filenames: true,
watch: true
};
this.middlewareOptions = options.middleware || {};
this.middlewareOptions.webpack = this.webpackOptions;

// Listening for events
this.webpackOptions.events = this.webpackOptions.events || new EventEmitter();
Expand All @@ -44,7 +46,7 @@ function Server(entry, options) {

app.configure(function() {
// serve webpack bundle
app.use(webpackDevMiddleware(entry, this.webpackOptions));
app.use(webpackDevMiddleware(entry, this.middlewareOptions));
}.bind(this));

// route live requests
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "webpack-dev-server",
"version": "0.7.2",
"version": "0.8.0",
"author": "Tobias Koppers @sokra",
"description": "Serves a webpack app. Updates the browser on changes.",
"dependencies": {
"webpack-dev-middleware": "0.7.x",
"webpack": "0.7.x",
"webpack-dev-middleware": "0.8.x",
"webpack": "0.8.x",
"express": "3.0.x",
"socket.io": "0.9.x",
"optimist": "0.3.x",
Expand Down

0 comments on commit 83d9909

Please sign in to comment.