Skip to content

Commit 38bc01c

Browse files
committed
Add missed changes
1 parent 1a3fa31 commit 38bc01c

File tree

5 files changed

+45
-44
lines changed

5 files changed

+45
-44
lines changed

packages/react-scripts/config/webpackDevServer.config.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var config = require('./webpack.config.dev');
22
var paths = require('./paths');
33

4-
var protocol = process.env.HTTPS === 'true' ? "https" : "http";
4+
var protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
55
var host = process.env.HOST || 'localhost';
66

77
module.exports = {
@@ -17,14 +17,16 @@ module.exports = {
1717
// project directory is dangerous because we may expose sensitive files.
1818
// Instead, we establish a convention that only files in `public` directory
1919
// get served. Our build script will copy `public` into the `build` folder.
20-
// In `index.html`, you can get URL of `public` folder with %PUBLIC_PATH%:
20+
// In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
2121
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
2222
// In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
2323
// Note that we only recommend to use `public` folder as an escape hatch
2424
// for files like `favicon.ico`, `manifest.json`, and libraries that are
2525
// for some reason broken when imported through Webpack. If you just want to
2626
// use an image, put it in `src` and `import` it from JavaScript instead.
2727
contentBase: paths.appPublic,
28+
// By default files from `contentBase` will not trigger a page reload.
29+
watchContentBase: true,
2830
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
2931
// for the WebpackDevServer client so it can learn when the files were
3032
// updated. The WebpackDevServer client is included as an entry point
@@ -43,6 +45,7 @@ module.exports = {
4345
ignored: /node_modules/
4446
},
4547
// Enable HTTPS if the HTTPS environment variable is set to 'true'
46-
https: protocol === "https",
47-
host: host
48+
https: protocol === 'https',
49+
host: host,
50+
overlay: false,
4851
};

packages/react-scripts/scripts/eject.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ prompt(
4949
'config',
5050
'config/jest',
5151
'scripts',
52-
'scripts/utils'
52+
'scripts/utils',
5353
];
5454

5555
// Make shallow array of files paths
@@ -75,24 +75,21 @@ prompt(
7575
});
7676

7777
files.forEach(function(file) {
78-
var content = fs.readFileSync(file, 'utf8')
78+
var content = fs.readFileSync(file, 'utf8');
7979

8080
// Skip flagged files
8181
if (content.match(/\/\/ @remove-file-on-eject/)) {
8282
return;
8383
}
84-
8584
content = content
8685
// Remove dead code from .js files on eject
8786
.replace(/\/\/ @remove-on-eject-begin([\s\S]*?)\/\/ @remove-on-eject-end/mg, '')
8887
// Remove dead code from .applescript files on eject
8988
.replace(/-- @remove-on-eject-begin([\s\S]*?)-- @remove-on-eject-end/mg, '')
9089
.trim() + '\n';
91-
92-
console.log(' Adding ' + cyan(file.replace(ownPath, '')) + ' to the project');
93-
fs.writeFileSync(file.replace(ownPath, appPath), content);
90+
console.log(' Adding ' + cyan(file) + ' to the project');
91+
fs.writeFileSync(path.join(appPath, file), content);
9492
});
95-
9693
console.log();
9794

9895
var ownPackage = require(path.join(ownPath, 'package.json'));

packages/react-scripts/scripts/start.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
4545
var DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
4646

4747
function run(port) {
48-
var protocol = process.env.HTTPS === 'true' ? "https" : "http";
48+
var protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
4949
var host = process.env.HOST || 'localhost';
5050

5151
// Create a webpack compiler that is configured with custom messages.

packages/react-scripts/scripts/utils/addWebpackMiddleware.js

+29-28
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,33 @@ var historyApiFallback = require('connect-history-api-fallback');
33
var httpProxyMiddleware = require('http-proxy-middleware');
44
var paths = require('../../config/paths');
55

6-
module.exports = function addMiddleware(devServer) {
6+
// We need to provide a custom onError function for httpProxyMiddleware.
7+
// It allows us to log custom error messages on the console.
8+
function onProxyError(proxy) {
9+
return function(err, req, res){
10+
var host = req.headers && req.headers.host;
11+
console.log(
12+
chalk.red('Proxy error:') + ' Could not proxy request ' + chalk.cyan(req.url) +
13+
' from ' + chalk.cyan(host) + ' to ' + chalk.cyan(proxy) + '.'
14+
);
15+
console.log(
16+
'See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (' +
17+
chalk.cyan(err.code) + ').'
18+
);
19+
console.log();
20+
21+
// And immediately send the proper error response to the client.
22+
// Otherwise, the request will eventually timeout with ERR_EMPTY_RESPONSE on the client side.
23+
if (res.writeHead && !res.headersSent) {
24+
res.writeHead(500);
25+
}
26+
res.end('Proxy error: Could not proxy request ' + req.url + ' from ' +
27+
host + ' to ' + proxy + ' (' + err.code + ').'
28+
);
29+
}
30+
}
31+
32+
module.exports = function addWebpackMiddleware(devServer) {
733
// `proxy` lets you to specify a fallback server during development.
834
// Every unrecognized request will be forwarded to it.
935
var proxy = require(paths.appPackageJson).proxy;
@@ -54,7 +80,8 @@ module.exports = function addMiddleware(devServer) {
5480
onError: onProxyError(proxy),
5581
secure: false,
5682
changeOrigin: true,
57-
ws: true
83+
ws: true,
84+
xfwd: true
5885
});
5986
devServer.use(mayProxy, hpm);
6087

@@ -68,29 +95,3 @@ module.exports = function addMiddleware(devServer) {
6895
// It may be /index.html, so let the dev server try serving it again.
6996
devServer.use(devServer.middleware);
7097
};
71-
72-
// We need to provide a custom onError function for httpProxyMiddleware.
73-
// It allows us to log custom error messages on the console.
74-
function onProxyError(proxy) {
75-
return function(err, req, res){
76-
var host = req.headers && req.headers.host;
77-
console.log(
78-
chalk.red('Proxy error:') + ' Could not proxy request ' + chalk.cyan(req.url) +
79-
' from ' + chalk.cyan(host) + ' to ' + chalk.cyan(proxy) + '.'
80-
);
81-
console.log(
82-
'See https://nodejs.org/api/errors.html#errors_common_system_errors for more information (' +
83-
chalk.cyan(err.code) + ').'
84-
);
85-
console.log();
86-
87-
// And immediately send the proper error response to the client.
88-
// Otherwise, the request will eventually timeout with ERR_EMPTY_RESPONSE on the client side.
89-
if (res.writeHead && !res.headersSent) {
90-
res.writeHead(500);
91-
}
92-
res.end('Proxy error: Could not proxy request ' + req.url + ' from ' +
93-
host + ' to ' + proxy + ' (' + err.code + ').'
94-
);
95-
}
96-
}

packages/react-scripts/scripts/utils/createWebpackCompiler.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ if (isSmokeTest) {
1919
};
2020
}
2121

22-
module.exports = function createCompiler(config, onReadyCallack) {
22+
module.exports = function createCompiler(config, onReadyCallback) {
2323
// "Compiler" is a low-level interface to Webpack.
2424
// It lets us listen to some events and provide our own custom messages.
2525
try {
@@ -64,8 +64,8 @@ module.exports = function createCompiler(config, onReadyCallack) {
6464
}
6565

6666
if (showInstructions) {
67-
if (typeof onReadyCallack === 'function') {
68-
onReadyCallack();
67+
if (typeof onReadyCallback === 'function') {
68+
onReadyCallback();
6969
}
7070
isFirstCompile = false;
7171
}
@@ -97,4 +97,4 @@ module.exports = function createCompiler(config, onReadyCallack) {
9797
});
9898

9999
return compiler;
100-
}
100+
};

0 commit comments

Comments
 (0)