Skip to content

Commit e54fcd8

Browse files
committed
Merge pull request react-bootstrap#758 from react-bootstrap/cross-browser-testing
Add means to load local dev docs on a different machine
2 parents 94a642c + 9536fa6 commit e54fcd8

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

docs/dev-run

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import 'colors';
44
import portfinder from 'portfinder';
55
import { exec } from 'child-process-promise';
6+
import ip from 'ip';
67

78
portfinder.basePort = 4000;
89

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

68-
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`);
69+
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()}`);
6970

7071
runCmd('docs-server', 'nodemon --watch docs --watch src --watch node_modules --exec babel-node docs/server.js', {
7172
env: {

docs/server.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import path from 'path';
55
import Router from 'react-router';
66
import routes from './src/Routes';
77
import httpProxy from 'http-proxy';
8+
import ip from 'ip';
89

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

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

4142
app.listen(port, function () {
42-
console.log(`Server started at http://localhost:${port}`);
43+
console.log(`Server started at:`);
44+
console.log(`- http://localhost:${port}`);
45+
console.log(`- http://${ip.address()}:${port}`);
4346
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"fs-extra": "^0.18.0",
6363
"fs-promise": "^0.3.1",
6464
"http-proxy": "^1.11.1",
65+
"ip": "^0.3.2",
6566
"json-loader": "^0.5.1",
6667
"karma": "~0.12.32",
6768
"karma-chai": "^0.1.0",

webpack/docs.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import _ from 'lodash';
22
import webpack from 'webpack';
33
import ExtractTextPlugin from 'extract-text-webpack-plugin';
44
import baseConfig, { options, jsLoader } from './base.config';
5+
import ip from 'ip';
56

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

0 commit comments

Comments
 (0)