diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index 3ff50d4e1b2036..e643f5839be268 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -3221,10 +3221,12 @@ async function compileLightningCSS( }) } catch (e) { e.message = `[lightningcss] ${e.message}` - e.loc = { - file: e.fileName.replace(NULL_BYTE_PLACEHOLDER, '\0'), - line: e.loc.line, - column: e.loc.column - 1, // 1-based + if (e.loc) { + e.loc = { + file: e.fileName.replace(NULL_BYTE_PLACEHOLDER, '\0'), + line: e.loc.line, + column: e.loc.column - 1, // 1-based + } } throw e }