From dc7c2683dae15c2c12619255ae983659fad477ef Mon Sep 17 00:00:00 2001 From: Megrax Date: Tue, 4 Oct 2022 00:22:02 +0800 Subject: [PATCH] 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 }