Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(asset): remove rollup 3 public file watch workaround #16331

Merged
merged 2 commits into from
Jul 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions packages/vite/src/node/plugins/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,6 @@ export function renderAssetUrlInJS(
return s
}

// During build, if we don't use a virtual file for public assets, rollup will
// watch for these ids resulting in watching the root of the file system in Windows,
const viteBuildPublicIdPrefix = '\0vite:asset:public'

/**
* Also supports loading plain strings with import text from './foo.txt?raw'
*/
Expand Down Expand Up @@ -164,17 +160,11 @@ export function assetPlugin(config: ResolvedConfig): Plugin {
// will fail to resolve in the main resolver. handle them here.
const publicFile = checkPublicFile(id, config)
if (publicFile) {
return config.command === 'build'
? `${viteBuildPublicIdPrefix}${id}`
: id
return id
}
},

async load(id) {
if (id.startsWith(viteBuildPublicIdPrefix)) {
id = id.slice(viteBuildPublicIdPrefix.length)
}

if (id[0] === '\0') {
// Rollup convention, this id should be handled by the
// plugin that marked it with \0
Expand Down