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

Commit

Permalink
WebSked mods
Browse files Browse the repository at this point in the history
  • Loading branch information
nvioli committed Oct 22, 2019
1 parent 4a30847 commit 9009bfa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 14 deletions.
28 changes: 19 additions & 9 deletions packages/react-scripts/config/webpackDevServer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
const evalSourceMapMiddleware = require('react-dev-utils/evalSourceMapMiddleware');
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
const ignoredFiles = require('react-dev-utils/ignoredFiles');
const redirectServedPath = require('react-dev-utils/redirectServedPathMiddleware');
const paths = require('./paths');
const fs = require('fs');

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

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

if (fs.existsSync(paths.proxySetup)) {
Expand All @@ -122,11 +126,17 @@ module.exports = function(proxy, allowedHost) {
// it used the same host and port.
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
// Should match `publicUrl` from Webpack config
app.use(
noopServiceWorkerMiddleware(
shouldUseRelativeAssetPaths ? '' : paths.servedPath.slice(0, -1)
)
);
app.use(function noopServiceWorkerMiddleware(req, res, next) {
const servedPath = shouldUseRelativeAssetPaths
? ''
: paths.servedPath.slice(0, -1);
if (req.url === `${servedPath}/service-worker.js`) {
res.setHeader('Content-Type', 'text/javascript');
res.send(`noop`);
} else {
next();
}
});
},
};
};
10 changes: 5 additions & 5 deletions packages/react-scripts/package.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{
"name": "react-scripts",
"version": "3.0.1",
"description": "Configuration and scripts for Create React App.",
"name": "websked-react-scripts",
"version": "3.0.2",
"description": "Arc WebSked Fork of Configuration and scripts for Create React App.",
"homepage": "/test",
"repository": {
"type": "git",
"url": "https://github.com/facebook/create-react-app.git",
"url": "https://github.com/wpmedia/create-react-app.git",
"directory": "packages/react-scripts"
},
"license": "MIT",
"engines": {
"node": ">=8.10"
},
"bugs": {
"url": "https://github.com/facebook/create-react-app/issues"
"url": "https://github.com/wpmedia/create-react-app/issues"
},
"files": [
"bin",
Expand Down

0 comments on commit 9009bfa

Please sign in to comment.