Skip to content
GitLab
Explore
Projects
Groups
Snippets
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
4a0f39ae
Commit
4a0f39ae
authored
8 years ago
by
Vincent Taing
Committed by
Dan Abramov
8 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Crash the app if it does not find index.html or index.js (#653)
parent
0be495fd
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
config/paths.js
+3
-0
config/paths.js
config/webpack.config.dev.js
+1
-1
config/webpack.config.dev.js
config/webpack.config.prod.js
+1
-1
config/webpack.config.prod.js
scripts/start.js
+18
-2
scripts/start.js
with
23 additions
and
4 deletions
+23
-4
config/paths.js
+
3
-
0
View file @
4a0f39ae
...
...
@@ -39,6 +39,7 @@ var nodePaths = (process.env.NODE_PATH || '')
module
.
exports
=
{
appBuild
:
resolveApp
(
'
build
'
),
appHtml
:
resolveApp
(
'
index.html
'
),
appIndexJs
:
resolveApp
(
'
src/index.js
'
),
appPackageJson
:
resolveApp
(
'
package.json
'
),
appSrc
:
resolveApp
(
'
src
'
),
testsSetup
:
resolveApp
(
'
src/setupTests.js
'
),
...
...
@@ -56,6 +57,7 @@ function resolveOwn(relativePath) {
module
.
exports
=
{
appBuild
:
resolveApp
(
'
build
'
),
appHtml
:
resolveApp
(
'
index.html
'
),
appIndexJs
:
resolveApp
(
'
src/index.js
'
),
appPackageJson
:
resolveApp
(
'
package.json
'
),
appSrc
:
resolveApp
(
'
src
'
),
testsSetup
:
resolveApp
(
'
src/setupTests.js
'
),
...
...
@@ -70,6 +72,7 @@ module.exports = {
module
.
exports
=
{
appBuild
:
resolveOwn
(
'
../build
'
),
appHtml
:
resolveOwn
(
'
../template/index.html
'
),
appIndexJs
:
resolveOwn
(
'
../template/src/index.js
'
),
appPackageJson
:
resolveOwn
(
'
../package.json
'
),
appSrc
:
resolveOwn
(
'
../template/src
'
),
testsSetup
:
resolveOwn
(
'
../template/src/setupTests.js
'
),
...
...
This diff is collapsed.
Click to expand it.
config/webpack.config.dev.js
+
1
-
1
View file @
4a0f39ae
...
...
@@ -49,7 +49,7 @@ module.exports = {
// We ship a few polyfills by default.
require
.
resolve
(
'
./polyfills
'
),
// Finally, this is your app's code:
path
.
join
(
paths
.
appSrc
,
'
i
ndex
'
)
path
s
.
appI
ndex
Js
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
...
...
This diff is collapsed.
Click to expand it.
config/webpack.config.prod.js
+
1
-
1
View file @
4a0f39ae
...
...
@@ -48,7 +48,7 @@ module.exports = {
// In production, we only want to load the polyfills and the app code.
entry
:
[
require
.
resolve
(
'
./polyfills
'
),
path
.
join
(
paths
.
appSrc
,
'
i
ndex
'
)
path
s
.
appI
ndex
Js
],
output
:
{
// The build folder.
...
...
This diff is collapsed.
Click to expand it.
scripts/start.js
+
18
-
2
View file @
4a0f39ae
...
...
@@ -11,6 +11,7 @@
process
.
env
.
NODE_ENV
=
'
development
'
;
var
fs
=
require
(
'
fs
'
);
var
path
=
require
(
'
path
'
);
var
chalk
=
require
(
'
chalk
'
);
var
webpack
=
require
(
'
webpack
'
);
...
...
@@ -170,6 +171,20 @@ function openBrowser(port, protocol) {
opn
(
protocol
+
'
://localhost:
'
+
port
+
'
/
'
);
}
function
checkRequiredFiles
()
{
var
filesPathToCheck
=
[
paths
.
appHtml
,
paths
.
appIndexJs
];
filesPathToCheck
.
forEach
(
function
(
filePath
)
{
try
{
fs
.
accessSync
(
filePath
,
fs
.
F_OK
);
}
catch
(
err
)
{
var
fileName
=
path
.
basename
(
filePath
);
console
.
log
(
chalk
.
red
(
`Cannot find
${
fileName
}
in
${
filePath
}
directory`
)
);
process
.
exit
(
1
);
}
});
}
// We need to provide a custom onError function for httpProxyMiddleware.
// It allows us to log custom error messages on the console.
function
onProxyError
(
proxy
)
{
...
...
@@ -180,7 +195,7 @@ function onProxyError(proxy) {
'
from
'
+
chalk
.
cyan
(
host
)
+
'
to
'
+
chalk
.
cyan
(
proxy
)
+
'
.
'
);
console
.
log
(
'
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (
'
+
'
See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (
'
+
chalk
.
cyan
(
err
.
code
)
+
'
).
'
);
console
.
log
();
...
...
@@ -190,7 +205,7 @@ function onProxyError(proxy) {
if
(
res
.
writeHead
&&
!
res
.
headersSent
)
{
res
.
writeHead
(
500
);
}
res
.
end
(
'
Proxy error: Could not proxy request
'
+
req
.
url
+
'
from
'
+
res
.
end
(
'
Proxy error: Could not proxy request
'
+
req
.
url
+
'
from
'
+
host
+
'
to
'
+
proxy
+
'
(
'
+
err
.
code
+
'
).
'
);
}
...
...
@@ -304,6 +319,7 @@ function runDevServer(port, protocol) {
function
run
(
port
)
{
var
protocol
=
process
.
env
.
HTTPS
===
'
true
'
?
"
https
"
:
"
http
"
;
checkRequiredFiles
();
setupCompiler
(
port
,
protocol
);
runDevServer
(
port
,
protocol
);
}
...
...
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
Menu
Explore
Projects
Groups
Snippets