Skip to content

Commit e564641

Browse files
authored
feat: add optional global configuration of root directory (#262)
1 parent 7303538 commit e564641

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

docs/configuration/config.md

+6
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,11 @@ Shared configuration to control the checker behaviors of the plugin.
5757
* @defaultValue `true`
5858
*/
5959
enableBuild: boolean
60+
61+
/**
62+
* Configure root directory of checkers
63+
* @defaultValue no default value
64+
*/
65+
root?: boolean;
6066
}
6167
```

packages/vite-plugin-checker/src/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ export function checker(userConfig: UserPluginConfig): Plugin {
175175
// Get the server instance and keep reference in a closure
176176
checkers.forEach((checker, index) => {
177177
const { worker, configureServer: workerConfigureServer } = checker.serve
178-
workerConfigureServer({ root: server.config.root })
178+
workerConfigureServer({ root: userConfig.root || server.config.root })
179179
worker.on('message', (action: Action) => {
180180
if (action.type === ACTION_TYPES.overlayError) {
181181
latestOverlayErrors[index] = action.payload as ClientDiagnosticPayload

packages/vite-plugin-checker/src/types.ts

+5
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ export interface SharedConfig {
160160
* @defaultValue `true`
161161
*/
162162
enableBuild: boolean
163+
/**
164+
* Configure root directory of checkers
165+
* @defaultValue no default value
166+
*/
167+
root?: string
163168
}
164169

165170
export interface BuildInCheckers {

0 commit comments

Comments
 (0)