Skip to content
This repository was archived by the owner on Mar 12, 2021. It is now read-only.

Commit 9009bfa

Browse files
committed
WebSked mods
1 parent 4a30847 commit 9009bfa

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

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

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
1212
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
13-
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
1413
const ignoredFiles = require('react-dev-utils/ignoredFiles');
15-
const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
1614
const paths = require('./paths');
1715
const fs = require('fs');
1816

@@ -63,7 +61,6 @@ module.exports = function(proxy, allowedHost) {
6361
// for some reason broken when imported through Webpack. If you just want to
6462
// use an image, put it in `src` and `import` it from JavaScript instead.
6563
contentBase: paths.appPublic,
66-
contentBasePublicPath: '/test',
6764
// By default files from `contentBase` will not trigger a page reload.
6865
watchContentBase: true,
6966
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
@@ -108,7 +105,14 @@ module.exports = function(proxy, allowedHost) {
108105

109106
// If servedPath is not relative redirect to `PUBLIC_URL` or `homepage` from `package.json`
110107
if (!shouldUseRelativeAssetPaths) {
111-
app.use(redirectServedPath(paths.servedPath.slice(0, -1)));
108+
const servedPath = paths.servedPath.slice(0, -1);
109+
app.use(function redirectServedPathMiddleware(req, res, next) {
110+
if (req.url === servedPath || req.url.startsWith(servedPath + '/')) {
111+
next();
112+
} else {
113+
res.redirect(`${servedPath}${req.path}`);
114+
}
115+
});
112116
}
113117

114118
if (fs.existsSync(paths.proxySetup)) {
@@ -122,11 +126,17 @@ module.exports = function(proxy, allowedHost) {
122126
// it used the same host and port.
123127
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
124128
// Should match `publicUrl` from Webpack config
125-
app.use(
126-
noopServiceWorkerMiddleware(
127-
shouldUseRelativeAssetPaths ? '' : paths.servedPath.slice(0, -1)
128-
)
129-
);
129+
app.use(function noopServiceWorkerMiddleware(req, res, next) {
130+
const servedPath = shouldUseRelativeAssetPaths
131+
? ''
132+
: paths.servedPath.slice(0, -1);
133+
if (req.url === `${servedPath}/service-worker.js`) {
134+
res.setHeader('Content-Type', 'text/javascript');
135+
res.send(`noop`);
136+
} else {
137+
next();
138+
}
139+
});
130140
},
131141
};
132142
};

packages/react-scripts/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
2-
"name": "react-scripts",
3-
"version": "3.0.1",
4-
"description": "Configuration and scripts for Create React App.",
2+
"name": "websked-react-scripts",
3+
"version": "3.0.2",
4+
"description": "Arc WebSked Fork of Configuration and scripts for Create React App.",
55
"homepage": "/test",
66
"repository": {
77
"type": "git",
8-
"url": "https://github.com/facebook/create-react-app.git",
8+
"url": "https://github.com/wpmedia/create-react-app.git",
99
"directory": "packages/react-scripts"
1010
},
1111
"license": "MIT",
1212
"engines": {
1313
"node": ">=8.10"
1414
},
1515
"bugs": {
16-
"url": "https://github.com/facebook/create-react-app/issues"
16+
"url": "https://github.com/wpmedia/create-react-app/issues"
1717
},
1818
"files": [
1919
"bin",

0 commit comments

Comments
 (0)