Skip to content

Commit 88251ef

Browse files
committed
fix: webpack-dev-server config
1 parent 0e81007 commit 88251ef

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Use `single-spa` `systemjs` in your `create-react-app`.
44

5-
> It is recommended to use the development mode to ensure stability !!!
5+
> Quickly adapt cra as a submodule of single-spa !!!
66
77
## Installation
88

@@ -22,15 +22,20 @@ const { rewiredSingleSpaDevServer } = require("react-app-rewired-single-spa");
2222

2323
module.exports = {
2424
webpack: rewiredSingleSpa(),
25-
devServer: rewiredSingleSpaDevServer,
25+
devServer: function (configFunction) {
26+
return function (proxy, allowedHost) {
27+
const config = configFunction(proxy, allowedHost);
28+
return rewiredSingleSpaDevServer()(config);
29+
};
30+
},
2631
};
2732

2833
// use `customize-cra`
29-
const { override } = require("customize-cra");
34+
const { override, overrideDevServer } = require("customize-cra");
3035

3136
module.exports = {
3237
webpack: override(rewiredSingleSpa()),
33-
devServer: rewiredSingleSpaDevServer,
38+
devServer: overrideDevServer(rewiredSingleSpaDevServer()),
3439
};
3540
```
3641

index.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ function rewiredSingleSpa({
4949
],
5050
});
5151

52-
return function (config, webpackEnv) {
53-
const isEnvProduction =
54-
(webpackEnv || process.env.BABEL_ENV) === "production";
52+
return function (config, webpackEnv = process.env.BABEL_ENV) {
53+
const isEnvProduction = webpackEnv === "production";
5554

5655
// amend input output
5756
config.output = {
@@ -155,12 +154,10 @@ function rewiredSingleSpa({
155154
};
156155
}
157156

158-
function rewiredSingleSpaDevServer(configFunction) {
157+
function rewiredSingleSpaDevServer() {
159158
const webpackMajorVersion = getWebpackMajorVersion();
160159

161-
return function (proxy, allowedHost) {
162-
const config = configFunction(proxy, allowedHost);
163-
160+
return function (config) {
164161
config.historyApiFallback = true;
165162
if (webpackMajorVersion < 5) {
166163
config.headers = {

0 commit comments

Comments
 (0)