Skip to content

Commit 13f93fc

Browse files
authored
feat: add an option to disable file watching (#387)
* feat: add an option to disable file watching * feat: disable watchers only based on the `CI` env var
1 parent ca71122 commit 13f93fc

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ export default createUnplugin<Options | undefined>((opt = {}, _meta) => {
7575
},
7676

7777
buildStart() {
78-
// TODO: how do we properly check if we are in dev mode?
79-
return ctx.scanPages(true)
78+
return ctx.scanPages(options.watch)
8079
},
8180

8281
buildEnd() {

src/options.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,15 @@ export interface ResolvedOptions {
178178
* @inheritDoc ParseSegmentOptions
179179
*/
180180
pathParser: ParseSegmentOptions
181+
182+
/**
183+
* Whether to watch the files for changes.
184+
*
185+
* Defaults to `true` unless the `CI` environment variable is set.
186+
*
187+
* @default `!process.env.CI`
188+
*/
189+
watch: boolean
181190
}
182191

183192
/**
@@ -210,6 +219,7 @@ export const DEFAULT_OPTIONS: ResolvedOptions = {
210219
pathParser: {
211220
dotNesting: true,
212221
},
222+
watch: !process.env.CI,
213223
}
214224

215225
export interface ServerContext {

0 commit comments

Comments
 (0)