diff --git a/bin/munseo.js b/bin/munseo.js index b99b13ad98..8a1e3aa22d 100644 --- a/bin/munseo.js +++ b/bin/munseo.js @@ -53,6 +53,7 @@ program .command('start [siteDir]') .description('Start development server') .option('-p, --port ', 'use specified port (default: 3000)') + .option('-h, --host ', 'use specified host (default: localhost') .option('-nw, --no-watch ', 'disable live reload (default: false)') .action((siteDir = '.', {port, noWatch}) => { wrapCommand(start)(path.resolve(siteDir), {port, noWatch}); diff --git a/lib/commands/start.js b/lib/commands/start.js index 3d766194d9..7c477511e5 100644 --- a/lib/commands/start.js +++ b/lib/commands/start.js @@ -14,6 +14,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin'); const load = require('../load'); const createClientConfig = require('../webpack/client'); +function getHost(reqHost) { + return reqHost || 'localhost'; +} + async function getPort(reqPort) { portfinder.basePort = parseInt(reqPort, 10) || 3000; const port = await portfinder.getPortPromise(); @@ -51,6 +55,7 @@ module.exports = async function start(siteDir, cliOptions = {}) { const port = await getPort(cliOptions.port); const hotPort = await getPort(port + 1); + const host = getHost(cliOptions.host); const {baseUrl} = props; // create compiler from generated webpack config @@ -85,6 +90,7 @@ module.exports = async function start(siteDir, cliOptions = {}) { }, logLevel: 'error', port, + host, add: app => { // serve static files const staticDir = path.resolve(siteDir, 'static');