From 979ef8b5a4b9c4cfc10a64aae8c29af53b8fae23 Mon Sep 17 00:00:00 2001 From: bluwy Date: Tue, 2 Apr 2024 10:37:06 +0800 Subject: [PATCH] refactor(asset): remove rollup 3 public file watch workaround --- packages/vite/src/node/plugins/asset.ts | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/vite/src/node/plugins/asset.ts b/packages/vite/src/node/plugins/asset.ts index 2ff5b101529982..67cda1abc11759 100644 --- a/packages/vite/src/node/plugins/asset.ts +++ b/packages/vite/src/node/plugins/asset.ts @@ -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' */ @@ -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