Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4a745c9

Browse files
committedFeb 7, 2018
fix(@angular/cli): adjust postcss url promise handling
1 parent 48b3b16 commit 4a745c9

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed
 

Diff for: ‎packages/@angular/cli/plugins/postcss-cli-resources.ts

+13-7
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,21 @@ export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResou
107107
};
108108

109109
return (root) => {
110-
const resourceCache = new Map<string, string>();
110+
const urlDeclarations: Array<postcss.Declaration> = [];
111+
root.walkDecls(decl => {
112+
if (decl.value && decl.value.includes('url')) {
113+
urlDeclarations.push(decl);
114+
}
115+
});
111116

112-
return root.walkDecls(async decl => {
113-
const value = decl.value;
117+
if (urlDeclarations.length === 0) {
118+
return;
119+
}
114120

115-
if (!value || value.indexOf('url') === -1) {
116-
return;
117-
}
121+
const resourceCache = new Map<string, string>();
118122

123+
return Promise.all(urlDeclarations.map(async decl => {
124+
const value = decl.value;
119125
const urlRegex = /url\(\s*['"]?([ \S]+?)['"]??\s*\)/g;
120126
const segments: string[] = [];
121127

@@ -149,6 +155,6 @@ export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResou
149155
if (modified) {
150156
decl.value = segments.join('');
151157
}
152-
});
158+
}));
153159
};
154160
});

0 commit comments

Comments
 (0)
Please sign in to comment.