Skip to content

Commit bc78e9d

Browse files
authored
fix: correct the type of include and exclude options (#8)
1 parent 76687b6 commit bc78e9d

2 files changed

Lines changed: 49 additions & 3 deletions

File tree

‎README.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,32 @@ module.exports = {
8383

8484
## Options
8585

86+
### include
87+
88+
- Type: [Rspack.RuleSetCondition](https://rspack.dev/config/module#condition)
89+
- Default: `/\.([jt]sx?)$/`
90+
91+
Include files to be processed by the plugin. The value is the same as the `rule.test` option in Rspack.
92+
93+
```js
94+
new PreactRefreshPlugin({
95+
include: [/\.jsx$/, /\.tsx$/],
96+
});
97+
```
98+
99+
### exclude
100+
101+
- Type: [Rspack.RuleSetCondition](https://rspack.dev/config/module#condition)
102+
- Default: `/node_modules/`
103+
104+
Exclude files from being processed by the plugin. The value is the same as the `rule.exclude` option in Rspack.
105+
106+
```js
107+
new PreactRefreshPlugin({
108+
exclude: [/node_modules/, /some-other-module/],
109+
});
110+
```
111+
86112
### preactPath
87113

88114
- Type: `string`

‎src/index.ts‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,31 @@
11
import fs from 'node:fs';
22
import { dirname } from 'node:path';
3-
import type { Compiler, RspackPluginInstance } from '@rspack/core';
3+
import type {
4+
Compiler,
5+
RspackPluginInstance,
6+
RuleSetCondition,
7+
} from '@rspack/core';
48

59
export interface IPreactRefreshRspackPluginOptions {
6-
include?: string | RegExp | (string | RegExp)[] | null;
7-
exclude?: string | RegExp | (string | RegExp)[] | null;
10+
/**
11+
* Include files to be processed by the plugin.
12+
* The value is the same as the `rule.test` option in Rspack.
13+
* @default /\.([jt]sx?)$/
14+
*/
15+
include?: RuleSetCondition | null;
16+
/**
17+
* Exclude files from being processed by the plugin.
18+
* The value is the same as the `rule.exclude` option in Rspack.
19+
* @default /node_modules/
20+
*/
21+
exclude?: RuleSetCondition | null;
22+
/**
23+
* Configure the error overlay.
24+
*/
825
overlay?: {
26+
/**
27+
* The module to use for the error overlay.
28+
*/
929
module: string;
1030
};
1131
/**

0 commit comments

Comments
 (0)