Skip to content

Commit c42cd5b

Browse files
committed
docs(overlay): refactor docs and document overlay options usage
1 parent 3ceeae2 commit c42cd5b

File tree

1 file changed

+64
-6
lines changed

1 file changed

+64
-6
lines changed

README.md

+64-6
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,71 @@ module.exports = api => {
105105
## Options
106106

107107
This plugin accepts a few options that are specifically targeted for advanced users.
108-
The allowed values are as follows:
109108

110-
| Name | Type | Default | Description |
111-
| :-----------------------: | :-------: | :-----: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
112-
| **`disableRefreshCheck`** | `boolean` | `false` | Disables detection of react-refresh's Babel plugin. Useful if you do not parse JS files within `node_modules`, or if you have a Babel setup not entirely controlled by Webpack. |
113-
| **`forceEnable`** | `boolean` | `false` | Enables the plugin forcefully. Useful if you want to use the plugin in production, or if you are using Webpack's `none` mode without `NODE_ENV`, for example. |
114-
| **`useLegacyWDSSockets`** | `boolean` | `false` | Set this to true if you are using a webpack-dev-server version prior to 3.8 as it requires a custom SocketJS implementation. If you use this, you will also need to install `sockjs-client` as a peer depencency. |
109+
### `options.disableRefreshCheck`
110+
111+
Type: `boolean`
112+
Default: `false`
113+
114+
Disables detection of react-refresh's Babel plugin.
115+
Useful if you do not parse JS files within `node_modules`, or if you have a Babel setup not entirely controlled by Webpack.
116+
117+
### `options.forceEnable`
118+
119+
Type: `boolean`
120+
Default: `false`
121+
122+
Enables the plugin forcefully.
123+
Useful if you want to use the plugin in production, or if you are using Webpack's `none` mode without `NODE_ENV`, for example.
124+
125+
### `options.overlay`
126+
127+
Type: `boolean | ErrorOverlayOptions`
128+
Default: `undefined`
129+
130+
Modifies how the error overlay integration works in the plugin.
131+
132+
- If `options.overlay` is not provided or is `true`, the plugin will use the bundled error overlay interation.
133+
- If `options.overlay` is `false`, it will disable the error overlay integration.
134+
- If an `ErrorOverlayOptions` object is provided:
135+
(**NOTE**: This is an advanced option that exists mostly for tools like `create-react-app` or `Next.js`)
136+
137+
- A `module` property must be defined.
138+
It should reference a JS file that exports at least two functions with footprints as follows:
139+
140+
```ts
141+
function handleRuntimeError(error: Error) {}
142+
function clearRuntimeErrors() {}
143+
```
144+
145+
- An optional `entry` property could also be defined, which should also reference a JS file that contains code needed to set up your custom error overlay integration.
146+
If it is not defined, the bundled error overlay entry will be used.
147+
It expects the `module` file to export two more functions:
148+
149+
```ts
150+
function showCompileError(webpackErrorMessage: string) {}
151+
function clearCompileErrors() {}
152+
```
153+
154+
Note that `webpackErrorMessage` is ANSI encoded, so you will need logic to parse it.
155+
156+
- An example configuration:
157+
```js
158+
const options = {
159+
overlay: {
160+
entry: 'some-webpack-entry-file',
161+
module: 'some-error-overlay-module',
162+
},
163+
};
164+
```
165+
166+
### `options.useLegacyWDSSockets`
167+
168+
Type: `boolean`
169+
Default: `false`
170+
171+
Set this to true if you are using a `webpack-dev-server` version prior to 3.8 as it requires a custom SockJS implementation.
172+
If you use this feature, you will also need to install `sockjs-client` as a peer dependency.
115173

116174
## Related Work
117175

0 commit comments

Comments
 (0)