|
2 | 2 |
|
3 | 3 | Use `single-spa` `systemjs` in your `create-react-app`.
|
4 | 4 |
|
5 |
| -> Quickly adapt cra as a submodule of single-spa !!! |
| 5 | +> Quickly adapt `react-scripts` as a submodule of single-spa !!! |
| 6 | + |
| 7 | +
|
| 8 | +## Features |
| 9 | + |
| 10 | +- Support `[email protected]` compatible with common configuration migrations |
| 11 | +- Output `systemjs` library auto add `SystemJSPublicPathPlugin` |
| 12 | +- Support `ReactFastRefresh` hot refresh |
6 | 13 |
|
7 | 14 | ## Installation
|
8 | 15 |
|
@@ -35,11 +42,69 @@ module.exports = {
|
35 | 42 | const { override, overrideDevServer } = require("customize-cra");
|
36 | 43 |
|
37 | 44 | module.exports = {
|
38 |
| - webpack: override(rewiredSingleSpa()), |
| 45 | + webpack: override( |
| 46 | + rewiredSingleSpa({ |
| 47 | + orgName: "you", |
| 48 | + projectName: "test", |
| 49 | + reactPackagesAsExternal: true, |
| 50 | + peerDepsAsExternal: true, |
| 51 | + orgPackagesAsExternal: true, |
| 52 | + }) |
| 53 | + ), |
39 | 54 | devServer: overrideDevServer(rewiredSingleSpaDevServer()),
|
40 | 55 | };
|
41 | 56 | ```
|
42 | 57 |
|
| 58 | +## Options |
| 59 | + |
| 60 | +### orgName |
| 61 | +Type: `string` |
| 62 | +The name of the organization this application is written for. |
| 63 | + |
| 64 | +### projectName |
| 65 | +Type: `string` |
| 66 | +The name of the current project. This usually matches the git repo's name. |
| 67 | + |
| 68 | +### entry |
| 69 | +Type: `string` |
| 70 | +Default: `src/{orgName}-{projectName}.{js|jsx|ts|tsx}` `src/index.{js|jsx|ts|tsx}` |
| 71 | +The entry file. |
| 72 | + |
| 73 | +### outputFilename |
| 74 | +Type: `string` |
| 75 | +Default: |
| 76 | + - development `{orgName}-{projectName}.[contenthash:8].js` |
| 77 | + - production `{orgName}-{projectName}.js` |
| 78 | + |
| 79 | +### rootDirectoryLevel |
| 80 | +Type: `number` |
| 81 | +This is the rootDirectoryLevel that is passed to https://github.com/joeldenning/systemjs-webpack-interop. |
| 82 | + |
| 83 | +### reactPackagesAsExternal |
| 84 | +Type: `boolean` |
| 85 | +This will `react` `react-dom` as webpack externals or not. |
| 86 | + |
| 87 | +### orgPackagesAsExternal |
| 88 | +Type: `boolean` |
| 89 | +This changes whether package names that start with @your-org-name are treated as webpack externals or not. |
| 90 | + |
| 91 | +### peerDepsAsExternal |
| 92 | +Type: `boolean` |
| 93 | +This will package.json `peerDependencies` as webpack externals or not. |
| 94 | + |
| 95 | +## FQA |
| 96 | + |
| 97 | +### FastRefresh invalid |
| 98 | +- If `react` `react-dom` is external, `react-dev-tool` must be installed to refresh automatically. |
| 99 | +For details, please see https://github.com/facebook/react/issues/17552 |
| 100 | +- Check whether the ws connection is normal, you can set in `.env` file |
| 101 | + - `WDS_SOCKET_PORT` "2002" |
| 102 | + - `WDS_SOCKET_HOST` "localhost" |
| 103 | + - `WDS_SOCKET_PATH` "/projectName" **Please start with "/"** |
| 104 | + > The default hotreload client uses the relative website protocol, |
| 105 | + which is the protocol of the main base. It can use the localhost |
| 106 | + protocol and the local development port. |
| 107 | + |
43 | 108 | ## License
|
44 | 109 |
|
45 | 110 | MIT © [fupengl](https://github.com/fupengl)
|
0 commit comments