From 9009bfa9302f087db63a4c4e3d7c61567d8866f0 Mon Sep 17 00:00:00 2001 From: Nick Violi Date: Tue, 22 Oct 2019 16:24:12 -0400 Subject: [PATCH] WebSked mods --- .../config/webpackDevServer.config.js | 28 +++++++++++++------ packages/react-scripts/package.json | 10 +++---- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/packages/react-scripts/config/webpackDevServer.config.js b/packages/react-scripts/config/webpackDevServer.config.js index 387725bec99..1025f73b084 100644 --- a/packages/react-scripts/config/webpackDevServer.config.js +++ b/packages/react-scripts/config/webpackDevServer.config.js @@ -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'); @@ -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 @@ -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)) { @@ -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(); + } + }); }, }; }; diff --git a/packages/react-scripts/package.json b/packages/react-scripts/package.json index 127c288eb73..8ba3a4f9a2a 100644 --- a/packages/react-scripts/package.json +++ b/packages/react-scripts/package.json @@ -1,11 +1,11 @@ { - "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", @@ -13,7 +13,7 @@ "node": ">=8.10" }, "bugs": { - "url": "https://github.com/facebook/create-react-app/issues" + "url": "https://github.com/wpmedia/create-react-app/issues" }, "files": [ "bin",