Skip to content

Commit

Permalink
fix(dev): add watch option passed to chokidar (#841)
Browse files Browse the repository at this point in the history
close #610 (comment), close #1153
  • Loading branch information
underfin authored Nov 27, 2020
1 parent 6ea0e85 commit a73c29b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { DepOptimizationOptions } from './optimizer'
import { ServerOptions } from 'https'
import { lookupFile } from './utils'
import { Options as RollupTerserOptions } from 'rollup-plugin-terser'
import { WatchOptions as chokidarWatchOptions } from 'chokidar'
import { ProxiesOptions } from './server/serverPluginProxy'

export type PreprocessLang = NonNullable<
Expand Down Expand Up @@ -281,6 +282,10 @@ export interface ServerConfig extends SharedConfig {
* of multiple server plugin functions.
*/
configureServer?: ServerPlugin | ServerPlugin[]
/**
* The watch option passed to `chokidar`.
*/
chokidarWatchOptions?: chokidarWatchOptions
}

export interface BuildConfig extends Required<SharedConfig> {
Expand Down
6 changes: 4 additions & 2 deletions src/node/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ export function createServer(config: ServerConfig): Server {
vueCustomBlockTransforms = {},
optimizeDeps = {},
enableEsbuild = true,
assetsInclude
assetsInclude,
chokidarWatchOptions = {}
} = config

const app = new Koa<State, Context>()
Expand All @@ -69,7 +70,8 @@ export function createServer(config: ServerConfig): Server {
awaitWriteFinish: {
stabilityThreshold: 100,
pollInterval: 10
}
},
...chokidarWatchOptions
}) as HMRWatcher
const resolver = createResolver(root, resolvers, alias, assetsInclude)

Expand Down

0 comments on commit a73c29b

Please sign in to comment.