Skip to content
This repository was archived by the owner on Dec 19, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions bin/underreact.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ const configOption = [
}
];

const hostOption = [
'host',
{
description: 'Host',
type: 'string',
default: '127.0.0.1'
}
];

const portOption = [
'port',
{
Expand Down Expand Up @@ -104,6 +113,7 @@ yargs
function defineStart(y) {
y.version(false)
.option(...configOption)
.option(...hostOption)
.option(...portOption)
.option(...modeOption('development'))
.option(...statsOption)
Expand Down
3 changes: 2 additions & 1 deletion commands/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,13 @@ function watchWebpack(urc) {
historyApiFallback: urc.devServerHistoryFallback && {
index: urc.siteBasePath
},
host: urc.host,
port: urc.port,
compress: urc.isProductionMode,
hot: urc.hot
});

server.listen(urc.port, '127.0.0.1', () => {
server.listen(urc.port, urc.host, () => {
resolve();
return;
});
Expand Down
5 changes: 5 additions & 0 deletions lib/config/__snapshots__/urc.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Urc {
"compileNodeModules": true,
"devServerHistoryFallback": false,
"environmentVariables": Object {},
"host": "127.0.0.1",
"hot": false,
"htmlSource": "
<!DOCTYPE html>
Expand Down Expand Up @@ -62,6 +63,7 @@ Urc {
"compileNodeModules": true,
"devServerHistoryFallback": false,
"environmentVariables": Object {},
"host": "127.0.0.1",
"hot": false,
"htmlSource": "
<!DOCTYPE html>
Expand Down Expand Up @@ -111,6 +113,7 @@ Urc {
"compileNodeModules": true,
"devServerHistoryFallback": false,
"environmentVariables": Object {},
"host": "127.0.0.1",
"hot": true,
"htmlSource": "
<!DOCTYPE html>
Expand Down Expand Up @@ -160,6 +163,7 @@ Urc {
"compileNodeModules": true,
"devServerHistoryFallback": false,
"environmentVariables": Object {},
"host": "127.0.0.1",
"hot": false,
"htmlSource": "
<!DOCTYPE html>
Expand Down Expand Up @@ -209,6 +213,7 @@ Urc {
"compileNodeModules": true,
"devServerHistoryFallback": false,
"environmentVariables": Object {},
"host": "127.0.0.1",
"hot": false,
"htmlSource": "
<!DOCTYPE html>
Expand Down
1 change: 1 addition & 0 deletions lib/config/validate-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function validateConfig(rawConfig = {}) {
browserslist: v.oneOfType(v.plainObject, v.arrayOf(v.string)),
compileNodeModules: v.oneOfType(v.boolean, v.arrayOf(v.string)),
devServerHistoryFallback: v.boolean,
host: v.string,
hot: v.boolean,
htmlSource: v.oneOfType(validatePromise, v.string, v.func),
jsEntry: validateAbsolutePaths,
Expand Down
1 change: 1 addition & 0 deletions lib/default-underreact.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = (cliOpts = {}) => {
modernBrowserTest: `'fetch' in window && 'assign' in Object`,
outputDirectory: path.join(rootDirectory, '_site'),
polyfill: path.resolve(underreactRoot, 'polyfill', 'index.js'),
host: cliOpts.host || '127.0.0.1',
port: cliOpts.port || 8080,
postcssPlugins: [],
publicAssetsPath: 'underreact-assets',
Expand Down
1 change: 1 addition & 0 deletions lib/utils/get-cli-opts.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ function getCliOpts(command, argv) {
configPath: path.resolve(argv.config),
mode: argv.mode,
stats: argv.stats,
host: argv.host,
port: argv.port
};
return cliOpts;
Expand Down