Skip to content

Commit bfd97e8

Browse files
committed
fix: syncMode - default: use append strategy when using dev server, overwrite strategy when using build.
1 parent e59fea4 commit bfd97e8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/core/context.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export class Context {
8080
return
8181

8282
this._server = server
83-
this._removeUnused = this.options.syncMode !== 'append'
8483
this.setupWatcher(server.watcher)
8584
}
8685

src/core/options.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { ComponentResolver, ComponentResolverObject, Options, ResolvedOptions } from '../types'
22
import { join, resolve } from 'node:path'
3+
import process from 'node:process'
34
import { slash, toArray } from '@antfu/utils'
45
import { getPackageInfoSync, isPackageExists } from 'local-pkg'
56
import { detectTypeImports } from './type-imports/detect'
@@ -73,6 +74,11 @@ export function resolveOptions(options: Options, root: string): ResolvedOptions
7374
throw new Error('[unplugin-vue-components] `extensions` option is required to search for components')
7475
}
7576

77+
// syncMode - `default`: use `append` strategy when using dev server, `overwrite` strategy when using build.
78+
if (resolved.syncMode === 'default') {
79+
resolved.syncMode = process.env.NODE_ENV === 'development' ? 'append' : 'overwrite'
80+
}
81+
7682
resolved.globsExclude = toArray(resolved.globsExclude || [])
7783
.map(i => resolveGlobsExclude(root, i))
7884

0 commit comments

Comments
 (0)