mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-10 23:57:22 +02:00
feat: able to specify host for dev (e.g: 0.0.0.0)
This commit is contained in:
parent
9965eec798
commit
8c6bc6dd38
2 changed files with 7 additions and 0 deletions
|
@ -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');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue