Skip to content

Commit

Permalink
fix(@angular/cli): adjust postcss url promise handling
Browse files Browse the repository at this point in the history
  • Loading branch information
clydin committed Feb 7, 2018
1 parent 48b3b16 commit 4a745c9
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions packages/@angular/cli/plugins/postcss-cli-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,21 @@ export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResou
};

return (root) => {
const resourceCache = new Map<string, string>();
const urlDeclarations: Array<postcss.Declaration> = [];
root.walkDecls(decl => {
if (decl.value && decl.value.includes('url')) {
urlDeclarations.push(decl);
}
});

return root.walkDecls(async decl => {
const value = decl.value;
if (urlDeclarations.length === 0) {
return;
}

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

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

Expand Down Expand Up @@ -149,6 +155,6 @@ export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResou
if (modified) {
decl.value = segments.join('');
}
});
}));
};
});

0 comments on commit 4a745c9

Please sign in to comment.