-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'lan' option (modify the option name to ‘useLocalIp’ for more sem…
…antic) (#901) * Add 'lan' option Let the browser open with local IP. * Add 'lan' option Let the browser open with local IP. * extract function getLocalIP and add some tests. * Change the option name to 'useLocalIp' and use 'internal-ip' to get local ip. * Fix confilcts.
- Loading branch information
1 parent
8d5f252
commit 7b3a42a
Showing
5 changed files
with
15 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
"use strict"; | ||
const url = require("url"); | ||
const internalIp = require("internal-ip"); | ||
|
||
module.exports = function createDomain(options) { | ||
const protocol = options.https ? "https" : "http"; | ||
|
||
// the formatted domain (url without path) of the webpack server | ||
return options.public ? `${protocol}://${options.public}` : url.format({ | ||
protocol: protocol, | ||
hostname: options.host, | ||
hostname: options.useLocalIp ? internalIp.v4() : options.host, | ||
port: options.socket ? 0 : options.port.toString() | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters