Skip to content

Commit d2a1a84

Browse files
fix: crash on modified AST from postcss-loader (#1268)
1 parent f1e0f00 commit d2a1a84

File tree

4 files changed

+27
-6
lines changed

4 files changed

+27
-6
lines changed

src/plugins/postcss-import-parser.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ function visitor(result, parsedResults, node, key) {
1414
return;
1515
}
1616

17-
if (node.raws.afterName && node.raws.afterName.trim().length > 0) {
17+
if (
18+
node.raws &&
19+
node.raws.afterName &&
20+
node.raws.afterName.trim().length > 0
21+
) {
1822
const lastCommentIndex = node.raws.afterName.lastIndexOf("/*");
1923
const matched = node.raws.afterName
2024
.slice(lastCommentIndex)

src/plugins/postcss-url-parser.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ function visitor(result, parsedResults, node, key) {
6868
}
6969

7070
const parsed = valueParser(
71-
typeof node.raws.value === "undefined" ? node[key] : node.raws.value.raw
71+
node.raws && node.raws.value && node.raws.value.raw
72+
? node.raws.value.raw
73+
: node[key]
7274
);
7375

7476
let inBetween;
7577

76-
if (typeof node.raws.between !== "undefined") {
78+
if (node.raws && node.raws.between) {
7779
const lastCommentIndex = node.raws.between.lastIndexOf("/*");
7880

7981
const matched = node.raws.between

0 commit comments

Comments
 (0)