Skip to content

Commit

Permalink
Merge pull request react-bootstrap#758 from react-bootstrap/cross-bro…
Browse files Browse the repository at this point in the history
…wser-testing

Add means to load local dev docs on a different machine
  • Loading branch information
mtscout6 committed May 29, 2015
2 parents 94a642c + 9536fa6 commit e54fcd8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion docs/dev-run
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import 'colors';
import portfinder from 'portfinder';
import { exec } from 'child-process-promise';
import ip from 'ip';

portfinder.basePort = 4000;

Expand Down Expand Up @@ -65,7 +66,7 @@ portfinder.getPorts(2, {}, (portFinderErr, [docsPort, webpackPort]) => {
process.exit(1);
}

runCmd('webpack-dev-server', `nodemon --watch webpack --watch webpack.docs.js --watch node_modules --exec webpack-dev-server -- --config webpack.docs.js --color --port ${webpackPort} --debug --hot`);
runCmd('webpack-dev-server', `nodemon --watch webpack --watch webpack.docs.js --watch node_modules --exec webpack-dev-server -- --config webpack.docs.js --color --port ${webpackPort} --debug --hot --host ${ip.address()}`);

runCmd('docs-server', 'nodemon --watch docs --watch src --watch node_modules --exec babel-node docs/server.js', {
env: {
Expand Down
7 changes: 5 additions & 2 deletions docs/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import path from 'path';
import Router from 'react-router';
import routes from './src/Routes';
import httpProxy from 'http-proxy';
import ip from 'ip';

const development = process.env.NODE_ENV !== 'production';
const port = process.env.PORT || 4000;
Expand All @@ -14,7 +15,7 @@ let app = express();
if (development) {
let proxy = httpProxy.createProxyServer();
let webpackPort = process.env.WEBPACK_DEV_PORT;
let target = `http://localhost:${webpackPort}`;
let target = `http://${ip.address()}:${webpackPort}`;

app.get('/assets/*', function (req, res) {
proxy.web(req, res, { target });
Expand All @@ -39,5 +40,7 @@ if (development) {
}

app.listen(port, function () {
console.log(`Server started at http://localhost:${port}`);
console.log(`Server started at:`);
console.log(`- http://localhost:${port}`);
console.log(`- http://${ip.address()}:${port}`);
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"fs-extra": "^0.18.0",
"fs-promise": "^0.3.1",
"http-proxy": "^1.11.1",
"ip": "^0.3.2",
"json-loader": "^0.5.1",
"karma": "~0.12.32",
"karma-chai": "^0.1.0",
Expand Down
3 changes: 2 additions & 1 deletion webpack/docs.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import _ from 'lodash';
import webpack from 'webpack';
import ExtractTextPlugin from 'extract-text-webpack-plugin';
import baseConfig, { options, jsLoader } from './base.config';
import ip from 'ip';

const webpackDevServerAddress = `http://localhost:${options.port}`;
const webpackDevServerAddress = `http://${ip.address()}:${options.port}`;
const cssSourceMap = options.debug ? '?sourceMap' : '';
const reactHot = options.debug ? 'react-hot!' : '';

Expand Down

0 comments on commit e54fcd8

Please sign in to comment.