This Gist works for CRA 3. For CRA 4, you can try community maintained craco plugin for converting to a single-spa application at https://github.com/hasanayan/craco-plugin-single-spa-application (thanks @hasanayan):
- Install react-app-rewired, as explained in https://github.com/timarney/react-app-rewired.
- Create a file in src called
single-spa-entry.js
(or tsx for typescript) - Modify config-overrides.js, as shown in the config-overrides.js file provided in this gist.
- (Optional) remove src/main.js, since single-spa-entry is the new entry
- (Optional) remove public/index.html, since single-spa applications share a single html file, instead of one html file per project.
@joeldenning I noticed that you did not override/ delete MiniCssExtractPlugin in this config. Since MiniCssExtractPlugin is already used in CRA project default config, if we don't do any thing about it, it gives us build code in separate folder js, css, media respectively. However, we'd like to align this config with single-spa webpack config as much as we can. I am wonder if we can do anything here. Thanks !