Skip to content

Commit

Permalink
fix: crash on modified AST from postcss-loader (#1268)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Mar 1, 2021
1 parent f1e0f00 commit d2a1a84
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
6 changes: 5 additions & 1 deletion src/plugins/postcss-import-parser.js
Expand Up @@ -14,7 +14,11 @@ function visitor(result, parsedResults, node, key) {
return;
}

if (node.raws.afterName && node.raws.afterName.trim().length > 0) {
if (
node.raws &&
node.raws.afterName &&
node.raws.afterName.trim().length > 0
) {
const lastCommentIndex = node.raws.afterName.lastIndexOf("/*");
const matched = node.raws.afterName
.slice(lastCommentIndex)
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/postcss-url-parser.js
Expand Up @@ -68,12 +68,14 @@ function visitor(result, parsedResults, node, key) {
}

const parsed = valueParser(
typeof node.raws.value === "undefined" ? node[key] : node.raws.value.raw
node.raws && node.raws.value && node.raws.value.raw
? node.raws.value.raw
: node[key]
);

let inBetween;

if (typeof node.raws.between !== "undefined") {
if (node.raws && node.raws.between) {
const lastCommentIndex = node.raws.between.lastIndexOf("/*");

const matched = node.raws.between
Expand Down

0 comments on commit d2a1a84

Please sign in to comment.