Skip to content

Commit

Permalink
Open the demo in browser on "npm start" (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cauê Alves authored and moroshko committed Aug 21, 2016
1 parent 3bece6d commit eb8758e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"less": "^2.6.1",
"less-loader": "^2.2.3",
"mocha": "^3.0.2",
"openurl": "^1.1.1",
"postcss-loader": "^0.10.1",
"react": "^15.0.1",
"react-addons-test-utils": "^15.0.1",
Expand Down
11 changes: 9 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
var webpack = require('webpack');
var WebpackDevServer = require('webpack-dev-server');
var openUrl = require('openurl');

var config = require('./webpack.dev.config');
var host = process.env.NODE_HOST || 'localhost';
var port = process.env.NODE_PORT || 3000;
Expand All @@ -9,7 +11,12 @@ new WebpackDevServer(webpack(config), {
}).listen(port, host, function(error) {
if (error) {
console.error(error); // eslint-disable-line no-console
} else {
console.log(`Demo is ready at http://${host}:${port}/demo/dist/index.html`); // eslint-disable-line no-console
process.exit(1);
}

var url = `http://${host}:${port}/demo/dist/index.html`;

console.log('Demo is ready at ' + url); // eslint-disable-line no-console

openUrl.open(url);
});

0 comments on commit eb8758e

Please sign in to comment.