From e7a497aa05afd494bfa4fad3fa148ef94ac5266b Mon Sep 17 00:00:00 2001 From: neverland Date: Sun, 3 Nov 2024 10:46:15 +0800 Subject: [PATCH] docs: complete options documentation (#8) --- README.md | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/options.ts | 16 +++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/README.md b/README.md index 63e8ebf..ac8de9e 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,61 @@ new ReactRefreshPlugin({ }); ``` +### forceEnable + +- Type: `boolean` +- Default: `false` + +Whether to force enable the plugin. + +By default, the plugin will not be enabled in non-development environments. If you want to force enable the plugin, you can set this option to `true`. + +```js +new ReactRefreshPlugin({ + forceEnable: true, +}); +``` + +It is useful if you want to: + +- Use the plugin in production. +- Use the plugin with the `none` mode without setting `NODE_ENV`. +- Use the plugin in environments we do not support, such as `electron-prerender` (**WARNING: Proceed at your own risk**). + +### library + +- Type: `string` +- Default: `output.uniqueName || output.library` + +Sets a namespace for the React Refresh runtime. + +It is most useful when multiple instances of React Refresh is running together simultaneously. + +### overlay + +- Type: `boolean | OverlayOptions` +- Default: `false` + +Modify the behavior of the error overlay. + +- Enable the error overlay: + +```js +new ReactRefreshPlugin({ + overlay: true, +}); +``` + +- Configure the error overlay: + +```js +new ReactRefreshPlugin({ + overlay: { + // ... + }, +}); +``` + ## Credits Thanks to the [react-refresh-webpack-plugin](https://github.com/pmmmwh/react-refresh-webpack-plugin) created by [@pmmmwh](https://github.com/pmmmwh), which inspires implement this plugin. diff --git a/src/options.ts b/src/options.ts index 0a89efb..7986f2f 100644 --- a/src/options.ts +++ b/src/options.ts @@ -24,8 +24,24 @@ export type PluginOptions = { * @default /node_modules/ */ exclude?: RuleSetCondition | null; + /** + * Sets a namespace for the React Refresh runtime. + * It is most useful when multiple instances of React Refresh is running + * together simultaneously. + * @default `output.uniqueName || output.library` + */ library?: string; + /** + * Whether to force enable the plugin. + * By default, the plugin will not be enabled in non-development environments. + * If you want to force enable the plugin, you can set this option to `true`. + * @default false + */ forceEnable?: boolean; + /** + * Modify the behavior of the error overlay. + * @default false + */ overlay?: boolean | OverlayOptions; };