From 9f268dad2e82c0f1276b1098c0a28f1cf245aa50 Mon Sep 17 00:00:00 2001 From: ZhengX <56376387+Megrax@users.noreply.github.com> Date: Mon, 24 Oct 2022 19:30:06 +0800 Subject: [PATCH] fix: add a warning if css urls not exist during build time (fix #9800) (#10331) 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 | 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 bdef18f08980ae..0663898da1d6f9 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -219,6 +219,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} referenced in ${id} didn't resolve at build time, it will remain unchanged to be resolved at runtime` + ) + } return url }