Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.

Commit e22a3fc

Browse files
authored
Enable setting the host to other than 127.0.0.1 (#101)
Unblocks being able to run in a docker container
1 parent 439c184 commit e22a3fc

File tree

6 files changed

+20
-1
lines changed

6 files changed

+20
-1
lines changed

bin/underreact.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ const configOption = [
4848
}
4949
];
5050

51+
const hostOption = [
52+
'host',
53+
{
54+
description: 'Host',
55+
type: 'string',
56+
default: '127.0.0.1'
57+
}
58+
];
59+
5160
const portOption = [
5261
'port',
5362
{
@@ -104,6 +113,7 @@ yargs
104113
function defineStart(y) {
105114
y.version(false)
106115
.option(...configOption)
116+
.option(...hostOption)
107117
.option(...portOption)
108118
.option(...modeOption('development'))
109119
.option(...statsOption)

commands/start.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,13 @@ function watchWebpack(urc) {
7676
historyApiFallback: urc.devServerHistoryFallback && {
7777
index: urc.siteBasePath
7878
},
79+
host: urc.host,
7980
port: urc.port,
8081
compress: urc.isProductionMode,
8182
hot: urc.hot
8283
});
8384

84-
server.listen(urc.port, '127.0.0.1', () => {
85+
server.listen(urc.port, urc.host, () => {
8586
resolve();
8687
return;
8788
});

lib/config/__snapshots__/urc.test.js.snap

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Urc {
1313
"compileNodeModules": true,
1414
"devServerHistoryFallback": false,
1515
"environmentVariables": Object {},
16+
"host": "127.0.0.1",
1617
"hot": false,
1718
"htmlSource": "
1819
<!DOCTYPE html>
@@ -62,6 +63,7 @@ Urc {
6263
"compileNodeModules": true,
6364
"devServerHistoryFallback": false,
6465
"environmentVariables": Object {},
66+
"host": "127.0.0.1",
6567
"hot": false,
6668
"htmlSource": "
6769
<!DOCTYPE html>
@@ -111,6 +113,7 @@ Urc {
111113
"compileNodeModules": true,
112114
"devServerHistoryFallback": false,
113115
"environmentVariables": Object {},
116+
"host": "127.0.0.1",
114117
"hot": true,
115118
"htmlSource": "
116119
<!DOCTYPE html>
@@ -160,6 +163,7 @@ Urc {
160163
"compileNodeModules": true,
161164
"devServerHistoryFallback": false,
162165
"environmentVariables": Object {},
166+
"host": "127.0.0.1",
163167
"hot": false,
164168
"htmlSource": "
165169
<!DOCTYPE html>
@@ -209,6 +213,7 @@ Urc {
209213
"compileNodeModules": true,
210214
"devServerHistoryFallback": false,
211215
"environmentVariables": Object {},
216+
"host": "127.0.0.1",
212217
"hot": false,
213218
"htmlSource": "
214219
<!DOCTYPE html>

lib/config/validate-config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ function validateConfig(rawConfig = {}) {
1212
browserslist: v.oneOfType(v.plainObject, v.arrayOf(v.string)),
1313
compileNodeModules: v.oneOfType(v.boolean, v.arrayOf(v.string)),
1414
devServerHistoryFallback: v.boolean,
15+
host: v.string,
1516
hot: v.boolean,
1617
htmlSource: v.oneOfType(validatePromise, v.string, v.func),
1718
jsEntry: validateAbsolutePaths,

lib/default-underreact.config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module.exports = (cliOpts = {}) => {
3030
modernBrowserTest: `'fetch' in window && 'assign' in Object`,
3131
outputDirectory: path.join(rootDirectory, '_site'),
3232
polyfill: path.resolve(underreactRoot, 'polyfill', 'index.js'),
33+
host: cliOpts.host || '127.0.0.1',
3334
port: cliOpts.port || 8080,
3435
postcssPlugins: [],
3536
publicAssetsPath: 'underreact-assets',

lib/utils/get-cli-opts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ function getCliOpts(command, argv) {
99
configPath: path.resolve(argv.config),
1010
mode: argv.mode,
1111
stats: argv.stats,
12+
host: argv.host,
1213
port: argv.port
1314
};
1415
return cliOpts;

0 commit comments

Comments
 (0)