silverwolf-x's picture
download
raw
1.21 kB
import { bold, cyan, red, yellow } from '../../../../lib/picocolors'
import { SimpleWebpackError } from './simpleWebpackError'
import { codeFrameColumns } from '../../../../shared/lib/errors/code-frame'
const regexScssError =
/SassError: (.+)\n\s+on line (\d+) [\s\S]*?>> (.+)\n\s*(-+)\^$/m
export function getScssError(
fileName: string,
fileContent: string | null,
err: Error
): SimpleWebpackError | false {
if (err.name !== 'SassError') {
return false
}
const res = regexScssError.exec(err.message)
if (res) {
const [, reason, _lineNumer, backupFrame, columnString] = res
const lineNumber = Math.max(1, parseInt(_lineNumer, 10))
const column = columnString?.length ?? 1
let frame: string | undefined
if (fileContent) {
try {
frame = codeFrameColumns(
fileContent,
{ start: { line: lineNumber, column } },
{ color: true, language: 'css' }
)
} catch {}
}
return new SimpleWebpackError(
`${cyan(fileName)}:${yellow(lineNumber.toString())}:${yellow(
column.toString()
)}`,
red(bold('Syntax error')).concat(`: ${reason}\n\n${frame || backupFrame}`)
)
}
return false
}

Xet Storage Details

Size:
1.21 kB
·
Xet hash:
686acf10792b38e41bf7a5ad786c8c4d42d0e4c92bca04544c14696bf94f8170

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.