diff --git a/packages/vite/src/node/plugins/css.ts b/packages/vite/src/node/plugins/css.ts index db8e0a2679f74f..f45a1ac01fb6f8 100644 --- a/packages/vite/src/node/plugins/css.ts +++ b/packages/vite/src/node/plugins/css.ts @@ -1316,8 +1316,10 @@ const less: StylePreprocessor = async (source, root, options, resolvers) => { return { code: '', errors: [normalizedError], deps: [] } } - const map: ExistingRawSourceMap = JSON.parse(result.map) - delete map.sourcesContent + const map: ExistingRawSourceMap = result.map && JSON.parse(result.map) + if (map) { + delete map.sourcesContent + } return { code: result.css.toString(),