diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 85a8b6daaf037c..48d19b14873aee 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -246,7 +246,7 @@ export function cssPostPlugin(config: ResolvedConfig): Plugin { return } - const modules = cssModulesCache.get(config)!.get(id) + const modules = cssModulesCache.get(config)?.get(id) const modulesCode = modules && dataToEsm(modules, { namedExports: true, preferConst: true })