feat: introduce syncMode to control the behavior of generating files#882
Merged
Conversation
|
|
antfu
approved these changes
Sep 20, 2025
Contributor
|
@kevinmarrec I found a bug doc say But in reality, the |
Contributor
|
@antfu 合并请求里,没有对 syncMode: 'default' 选项做任何处理,只是不等于 'append' 就默认执行了 'overwrite' 的效果。 导致在启动 dev-server 开发时,运行了一个页面,会把其他页面的 icon 自动导入全部删除。 setupViteServer(server: ViteDevServer) {
if (this._server === server)
return
this._server = server
this._removeUnused = this.options.syncMode !== 'append'
this.setupWatcher(server.watcher)
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduce the
syncModeoption to control the behavior of generating files.Default to
defaultappend: only append the new components to the existing files.overwrite: overwrite the whole existing files with the current components.default: useappendstrategy when using dev server,overwritestrategy when using build.Linked Issues
Resolves #804 (Please confirm⚠️ )
Linked Pull Requests
Closes #844
Additional context
Current logic is
removeUnused === !this._server, which means only remove unused components when building and is dependent on vite mode ("Is there a dev server ?").To prevent any breaking change, a
defaultmode is required to follow current behavior, whileappendmode will always append which means also append with vite build.