From dc7c2683dae15c2c12619255ae983659fad477ef Mon Sep 17 00:00:00 2001 From: Megrax Date: Tue, 4 Oct 2022 00:22:02 +0800 Subject: [PATCH 1/2] fix: add a warning if css urls not exist during build time (fix #9800) --- packages/vite/src/node/plugins/css.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 824dc8d571c91e..3403b854d16a62 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -217,6 +217,12 @@ export function cssPlugin(config: ResolvedConfig): Plugin { if (resolved) { return fileToUrl(resolved, config, this) } + if (config.command === 'build') { + // #9800 If we cannot resolve the css url, leave a warning. + config.logger.warnOnce( + `\n${url} doesn't exist at build time, it will remain unchanged to be resolved at runtime` + ) + } return url } From 619ef501698e521adf25ff6dbb344273c7b6dc29 Mon Sep 17 00:00:00 2001 From: ZhengX <56376387+Megrax@users.noreply.github.com> Date: Thu, 20 Oct 2022 13:58:41 +0800 Subject: [PATCH 2/2] chore: update message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 翠 / green --- packages/vite/src/node/plugins/css.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 3403b854d16a62..d1a54f05c9e754 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -220,7 +220,7 @@ export function cssPlugin(config: ResolvedConfig): Plugin { if (config.command === 'build') { // #9800 If we cannot resolve the css url, leave a warning. config.logger.warnOnce( - `\n${url} doesn't exist at build time, it will remain unchanged to be resolved at runtime` + `\n${url} referenced in ${id} didn't resolve at build time, it will remain unchanged to be resolved at runtime` ) } return url