Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Meta
create-react-app
Commits
ac63130a
Commit
ac63130a
authored
7 years ago
by
Joe Haddad
Committed by
Dan Abramov
7 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Show network address on start (#2155)
* Show network address on start * Tweak visual representation
parent
4dc7c865
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
packages/react-scripts/config/webpackDevServer.config.js
+2
-1
packages/react-scripts/config/webpackDevServer.config.js
packages/react-scripts/package.json
+2
-1
packages/react-scripts/package.json
packages/react-scripts/scripts/start.js
+30
-18
packages/react-scripts/scripts/start.js
with
34 additions
and
20 deletions
+34
-20
packages/react-scripts/config/webpackDevServer.config.js
+
2
-
1
View file @
ac63130a
...
@@ -17,7 +17,7 @@ const paths = require('./paths');
...
@@ -17,7 +17,7 @@ const paths = require('./paths');
const
protocol
=
process
.
env
.
HTTPS
===
'
true
'
?
'
https
'
:
'
http
'
;
const
protocol
=
process
.
env
.
HTTPS
===
'
true
'
?
'
https
'
:
'
http
'
;
const
host
=
process
.
env
.
HOST
||
'
0.0.0.0
'
;
const
host
=
process
.
env
.
HOST
||
'
0.0.0.0
'
;
module
.
exports
=
function
(
proxy
)
{
module
.
exports
=
function
(
proxy
,
allowedHost
)
{
return
{
return
{
// Enable gzip compression of generated files.
// Enable gzip compression of generated files.
compress
:
true
,
compress
:
true
,
...
@@ -67,6 +67,7 @@ module.exports = function(proxy) {
...
@@ -67,6 +67,7 @@ module.exports = function(proxy) {
// See https://github.com/facebookincubator/create-react-app/issues/387.
// See https://github.com/facebookincubator/create-react-app/issues/387.
disableDotRule
:
true
,
disableDotRule
:
true
,
},
},
public
:
allowedHost
,
proxy
,
proxy
,
setup
(
app
)
{
setup
(
app
)
{
// This lets us open files from the crash overlay.
// This lets us open files from the crash overlay.
...
...
This diff is collapsed.
Click to expand it.
packages/react-scripts/package.json
+
2
-
1
View file @
ac63130a
...
@@ -21,6 +21,8 @@
...
@@ -21,6 +21,8 @@
"react-scripts"
:
"./bin/react-scripts.js"
"react-scripts"
:
"./bin/react-scripts.js"
},
},
"dependencies"
:
{
"dependencies"
:
{
"@timer/detect-port"
:
"1.1.2"
,
"address"
:
"1.0.1"
,
"autoprefixer"
:
"6.7.7"
,
"autoprefixer"
:
"6.7.7"
,
"babel-core"
:
"6.23.1"
,
"babel-core"
:
"6.23.1"
,
"babel-eslint"
:
"7.1.1"
,
"babel-eslint"
:
"7.1.1"
,
...
@@ -33,7 +35,6 @@
...
@@ -33,7 +35,6 @@
"connect-history-api-fallback"
:
"1.3.0"
,
"connect-history-api-fallback"
:
"1.3.0"
,
"cross-spawn"
:
"4.0.2"
,
"cross-spawn"
:
"4.0.2"
,
"css-loader"
:
"0.28.0"
,
"css-loader"
:
"0.28.0"
,
"@timer/detect-port"
:
"1.1.2"
,
"dotenv"
:
"2.0.0"
,
"dotenv"
:
"2.0.0"
,
"eslint"
:
"3.16.1"
,
"eslint"
:
"3.16.1"
,
"eslint-config-react-app"
:
"^0.6.1"
,
"eslint-config-react-app"
:
"^0.6.1"
,
...
...
This diff is collapsed.
Click to expand it.
packages/react-scripts/scripts/start.js
+
30
-
18
View file @
ac63130a
...
@@ -22,6 +22,7 @@ process.env.NODE_ENV = 'development';
...
@@ -22,6 +22,7 @@ process.env.NODE_ENV = 'development';
// Ensure environment variables are read.
// Ensure environment variables are read.
require
(
'
../config/env
'
);
require
(
'
../config/env
'
);
const
address
=
require
(
'
address
'
);
const
fs
=
require
(
'
fs
'
);
const
fs
=
require
(
'
fs
'
);
const
chalk
=
require
(
'
chalk
'
);
const
chalk
=
require
(
'
chalk
'
);
const
detect
=
require
(
'
@timer/detect-port
'
);
const
detect
=
require
(
'
@timer/detect-port
'
);
...
@@ -53,25 +54,23 @@ const HOST = process.env.HOST || '0.0.0.0';
...
@@ -53,25 +54,23 @@ const HOST = process.env.HOST || '0.0.0.0';
function
run
(
port
)
{
function
run
(
port
)
{
const
protocol
=
process
.
env
.
HTTPS
===
'
true
'
?
'
https
'
:
'
http
'
;
const
protocol
=
process
.
env
.
HTTPS
===
'
true
'
?
'
https
'
:
'
http
'
;
const
formattedUrl
=
url
.
format
({
protocol
,
hostname
:
HOST
,
port
,
pathname
:
'
/
'
,
});
let
prettyHost
;
const
formatUrl
=
hostname
=>
if
(
HOST
===
'
0.0.0.0
'
||
HOST
===
'
::
'
)
{
url
.
format
({
protocol
,
hostname
,
port
,
pathname
:
'
/
'
});
const
isUnspecifiedAddress
=
HOST
===
'
0.0.0.0
'
||
HOST
===
'
::
'
;
let
prettyHost
,
lanAddress
;
if
(
isUnspecifiedAddress
)
{
prettyHost
=
'
localhost
'
;
prettyHost
=
'
localhost
'
;
try
{
lanAddress
=
address
.
ip
();
}
catch
(
_e
)
{
// ignored
}
}
else
{
}
else
{
prettyHost
=
HOST
;
prettyHost
=
HOST
;
}
}
const
prettyUrl
=
url
.
format
({
const
prettyUrl
=
formatUrl
(
prettyHost
);
protocol
,
hostname
:
prettyHost
,
port
,
pathname
:
'
/
'
,
});
// Create a webpack compiler that is configured with custom messages.
// Create a webpack compiler that is configured with custom messages.
const
compiler
=
createWebpackCompiler
(
const
compiler
=
createWebpackCompiler
(
...
@@ -81,9 +80,22 @@ function run(port) {
...
@@ -81,9 +80,22 @@ function run(port) {
return
;
return
;
}
}
console
.
log
();
console
.
log
();
console
.
log
(
'
The app is running at:
'
);
console
.
log
(
`You can now view
${
chalk
.
bold
(
require
(
paths
.
appPackageJson
).
name
)}
in the browser.`
);
console
.
log
();
console
.
log
();
console
.
log
(
`
${
chalk
.
cyan
(
formattedUrl
)}
`
);
if
(
isUnspecifiedAddress
&&
lanAddress
)
{
console
.
log
(
`
${
chalk
.
bold
(
'
Local:
'
)}
${
chalk
.
cyan
(
prettyUrl
)}
`
);
console
.
log
(
`
${
chalk
.
bold
(
'
On Your Network:
'
)}
${
chalk
.
cyan
(
formatUrl
(
lanAddress
))}
`
);
}
else
{
console
.
log
(
`
${
chalk
.
cyan
(
prettyUrl
)}
`
);
}
console
.
log
();
console
.
log
();
console
.
log
(
'
Note that the development build is not optimized.
'
);
console
.
log
(
'
Note that the development build is not optimized.
'
);
console
.
log
(
console
.
log
(
...
@@ -98,7 +110,7 @@ function run(port) {
...
@@ -98,7 +110,7 @@ function run(port) {
// Serve webpack assets generated by the compiler over a web sever.
// Serve webpack assets generated by the compiler over a web sever.
const
devServer
=
new
WebpackDevServer
(
const
devServer
=
new
WebpackDevServer
(
compiler
,
compiler
,
devServerConfig
(
prepareProxy
(
proxy
))
devServerConfig
(
prepareProxy
(
proxy
)
,
lanAddress
)
);
);
// Launch WebpackDevServer.
// Launch WebpackDevServer.
...
@@ -113,7 +125,7 @@ function run(port) {
...
@@ -113,7 +125,7 @@ function run(port) {
console
.
log
(
chalk
.
cyan
(
'
Starting the development server...
'
));
console
.
log
(
chalk
.
cyan
(
'
Starting the development server...
'
));
console
.
log
();
console
.
log
();
openBrowser
(
pretty
Url
);
openBrowser
(
formatUrl
(
pretty
Host
)
);
});
});
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment