Skip to content

Commit

Permalink
feat(CRA-start): bump webpack-dev-server to 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sabertazimi committed Aug 19, 2021
1 parent 0848fa5 commit 84c8cd9
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 41 deletions.
64 changes: 39 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions packages/react-scripts/config/webpackDevServer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,27 @@ module.exports = function (proxy, allowedHost) {
},
// `proxy` is run between `before` and `after` `webpack-dev-server` hooks
proxy,
onBeforeSetupMiddleware(app, server) {
onBeforeSetupMiddleware(devServer) {
// Keep `evalSourceMapMiddleware`
// middlewares before `redirectServedPath` otherwise will not have any effect
// This lets us fetch source contents from webpack for the error overlay
app.use(evalSourceMapMiddleware(server));
devServer.app.use(evalSourceMapMiddleware(devServer));

if (fs.existsSync(paths.proxySetup)) {
// This registers user provided middleware for proxy reasons
require(paths.proxySetup)(app);
require(paths.proxySetup)(devServer.app);
}
},
onAfterSetupMiddleware(app) {
onAfterSetupMiddleware(devServer) {
// Redirect to `PUBLIC_URL` or `homepage` from `package.json` if url not match
app.use(redirectServedPath(paths.publicUrlOrPath));
devServer.app.use(redirectServedPath(paths.publicUrlOrPath));

// This service worker file is effectively a 'no-op' that will reset any
// previous service worker registered for the same host:port combination.
// We do this in development to avoid hitting the production cache if
// it used the same host and port.
// https://github.com/facebook/create-react-app/issues/2272#issuecomment-302832432
app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
devServer.app.use(noopServiceWorkerMiddleware(paths.publicUrlOrPath));
},
};
};
2 changes: 1 addition & 1 deletion packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
"stylelint-webpack-plugin": "^3.0.1",
"webpack": "5.50.0",
"webpack-bundle-analyzer": "^4.4.2",
"webpack-dev-server": "4.0.0-rc.0",
"webpack-dev-server": "4.0.0",
"webpack-manifest-plugin": "4.0.2",
"workbox-webpack-plugin": "6.2.4"
},
Expand Down
16 changes: 7 additions & 9 deletions packages/react-scripts/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,14 @@ checkBrowsers(paths.appPath, isInteractive)
paths.publicUrlOrPath
);
// Serve webpack assets generated by the compiler over a web server.
const serverConfig = createDevServerConfig(
proxyConfig,
urls.lanUrlForConfig
);
const devServer = new WebpackDevServer(compiler, serverConfig);
const serverConfig = {
...createDevServerConfig(proxyConfig, urls.lanUrlForConfig),
host: HOST,
port,
};
const devServer = new WebpackDevServer(serverConfig, compiler);
// Launch WebpackDevServer.
devServer.listen(port, HOST, err => {
if (err) {
return console.log(err);
}
devServer.startCallback(() => {
if (isInteractive) {
clearConsole();
}
Expand Down

0 comments on commit 84c8cd9

Please sign in to comment.