Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,46 @@
const path = require("path");
const WebpackDevServer = require("webpack-dev-server");

const TS1208 = "TS1208";

// react-scripts 5 shuts the server down with the WDS 4 `close()` API.
// WDS 5 renamed it to `stopCallback()`, so retain graceful shutdowns.
if (!WebpackDevServer.prototype.close) {
WebpackDevServer.prototype.close = function close(callback) {
this.stopCallback(callback);
};
}

module.exports = {
// Configuration for React app customization
// Currently minimal setup - can be extended as needed
style: {
postcss: { mode: "file" },
},
devServer: (devServerConfig) => {
// react-scripts 5 still emits webpack-dev-server 4 options. Translate the
// removed hooks/options so we can use the patched webpack-dev-server 5.
const {
onBeforeSetupMiddleware,
onAfterSetupMiddleware,
https,
...compatibleConfig
} = devServerConfig;

compatibleConfig.server = https
? {
type: "https",
...(typeof https === "object" ? { options: https } : {}),
}
: "http";
compatibleConfig.setupMiddlewares = (middlewares, devServer) => {
onBeforeSetupMiddleware?.(devServer);
onAfterSetupMiddleware?.(devServer);
return middlewares;
};

return compatibleConfig;
},
webpack: {
alias: {
"@": path.resolve(__dirname, "src"),
Expand Down
Loading