Skip to content

Commit 48c7a85

Browse files
committed
refactor(@angular-devkit/build-angular): support postcss 8
This change updates the internal postcss plugins to use the postcss 8 API as well as updates the versions of all external plugins to postcss 8 supported versions.
1 parent 3acd694 commit 48c7a85

File tree

4 files changed

+65
-39
lines changed

4 files changed

+65
-39
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@
186186
"pidusage": "^2.0.17",
187187
"pnp-webpack-plugin": "1.6.4",
188188
"popper.js": "^1.14.1",
189-
"postcss": "7.0.32",
190-
"postcss-import": "12.0.1",
189+
"postcss": "8.1.7",
190+
"postcss-import": "13.0.0",
191191
"postcss-loader": "4.0.4",
192192
"prettier": "^2.0.0",
193193
"protractor": "~7.0.0",

packages/angular_devkit/build_angular/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
2121
"@ngtools/webpack": "0.0.0",
2222
"ansi-colors": "4.1.1",
23-
"autoprefixer": "9.8.6",
23+
"autoprefixer": "10.0.2",
2424
"babel-loader": "8.2.1",
2525
"browserslist": "^4.9.1",
2626
"cacache": "15.0.5",
@@ -46,8 +46,8 @@
4646
"ora": "5.1.0",
4747
"parse5-html-rewriting-stream": "6.0.1",
4848
"pnp-webpack-plugin": "1.6.4",
49-
"postcss": "7.0.32",
50-
"postcss-import": "12.0.1",
49+
"postcss": "8.1.7",
50+
"postcss-import": "13.0.0",
5151
"postcss-loader": "4.0.4",
5252
"raw-loader": "4.0.2",
5353
"regenerator-runtime": "0.13.7",

packages/angular_devkit/build_angular/src/webpack/plugins/postcss-cli-resources.ts

+16-18
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88
import { interpolateName } from 'loader-utils';
99
import * as path from 'path';
10-
import * as postcss from 'postcss';
10+
import { Declaration, Plugin } from 'postcss';
1111
import * as url from 'url';
1212
import * as webpack from 'webpack';
1313

@@ -48,14 +48,15 @@ async function resolve(
4848
}
4949
}
5050

51-
export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResourcesOptions | undefined) => {
51+
export const postcss = true;
52+
53+
export default function(options?: PostcssCliResourcesOptions): Plugin {
5254
if (!options) {
5355
throw new Error('No options were specified to "postcss-cli-resources".');
5456
}
5557

5658
const {
5759
deployUrl = '',
58-
baseHref = '',
5960
resourcesOutputPath = '',
6061
filename,
6162
loader,
@@ -141,21 +142,16 @@ export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResou
141142
});
142143
};
143144

144-
return (root) => {
145-
const urlDeclarations: Array<postcss.Declaration> = [];
146-
root.walkDecls(decl => {
147-
if (decl.value && decl.value.includes('url')) {
148-
urlDeclarations.push(decl);
149-
}
150-
});
151-
152-
if (urlDeclarations.length === 0) {
153-
return;
154-
}
145+
const resourceCache = new Map<string, string>();
146+
const processed = Symbol('postcss-cli-resources');
155147

156-
const resourceCache = new Map<string, string>();
148+
return {
149+
postcssPlugin: 'postcss-cli-resources',
150+
async Declaration(decl) {
151+
if (!decl.value.includes('url') || processed in decl) {
152+
return;
153+
}
157154

158-
return Promise.all(urlDeclarations.map(async decl => {
159155
const value = decl.value;
160156
const urlRegex = /url\(\s*(?:"([^"]+)"|'([^']+)'|(.+?))\s*\)/g;
161157
const segments: string[] = [];
@@ -200,6 +196,8 @@ export default postcss.plugin('postcss-cli-resources', (options: PostcssCliResou
200196
if (modified) {
201197
decl.value = segments.join('');
202198
}
203-
}));
199+
200+
(decl as Declaration & { [processed]: boolean })[processed] = true;
201+
},
204202
};
205-
});
203+
}

yarn.lock

+44-16
Original file line numberDiff line numberDiff line change
@@ -2618,6 +2618,18 @@ atob@^2.1.2:
26182618
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
26192619
integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==
26202620

2621+
autoprefixer@10.0.2:
2622+
version "10.0.2"
2623+
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-10.0.2.tgz#a79f9a02bfb95c621998776ac0d85f8f855b367e"
2624+
integrity sha512-okBmu9OMdt6DNEcZmnl0IYVv8Xl/xYWRSnc2OJ9UJEOt1u30opG1B8aLsViqKryBaYv1SKB4f85fOGZs5zYxHQ==
2625+
dependencies:
2626+
browserslist "^4.14.7"
2627+
caniuse-lite "^1.0.30001157"
2628+
colorette "^1.2.1"
2629+
normalize-range "^0.1.2"
2630+
num2fraction "^1.2.2"
2631+
postcss-value-parser "^4.1.0"
2632+
26212633
autoprefixer@9.8.6, autoprefixer@^9.6.5:
26222634
version "9.8.6"
26232635
resolved "https://registry.yarnpkg.com/autoprefixer/-/autoprefixer-9.8.6.tgz#3b73594ca1bf9266320c5acf1588d74dea74210f"
@@ -2968,6 +2980,17 @@ browserslist@^4.0.0, browserslist@^4.12.0, browserslist@^4.14.5, browserslist@^4
29682980
escalade "^3.1.1"
29692981
node-releases "^1.1.65"
29702982

2983+
browserslist@^4.14.7:
2984+
version "4.14.7"
2985+
resolved "https://registry.yarnpkg.com/browserslist/-/browserslist-4.14.7.tgz#c071c1b3622c1c2e790799a37bb09473a4351cb6"
2986+
integrity sha512-BSVRLCeG3Xt/j/1cCGj1019Wbty0H+Yvu2AOuZSuoaUWn3RatbL33Cxk+Q4jRMRAbOm0p7SLravLjpnT6s0vzQ==
2987+
dependencies:
2988+
caniuse-lite "^1.0.30001157"
2989+
colorette "^1.2.1"
2990+
electron-to-chromium "^1.3.591"
2991+
escalade "^3.1.1"
2992+
node-releases "^1.1.66"
2993+
29712994
browserstack@^1.5.1:
29722995
version "1.6.0"
29732996
resolved "https://registry.yarnpkg.com/browserstack/-/browserstack-1.6.0.tgz#5a56ab90987605d9c138d7a8b88128370297f9bf"
@@ -3259,7 +3282,7 @@ caniuse-api@^3.0.0:
32593282
lodash.memoize "^4.1.2"
32603283
lodash.uniq "^4.5.0"
32613284

3262-
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001032, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001154:
3285+
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001032, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001154, caniuse-lite@^1.0.30001157:
32633286
version "1.0.30001157"
32643287
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001157.tgz#2d11aaeb239b340bc1aa730eca18a37fdb07a9ab"
32653288
integrity sha512-gOerH9Wz2IRZ2ZPdMfBvyOi3cjaz4O4dgNwPGzx8EhqAs4+2IL/O+fJsbt+znSigujoZG8bVcIAUM/I/E5K3MA==
@@ -4730,6 +4753,11 @@ electron-to-chromium@^1.3.585:
47304753
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.591.tgz#a18892bf1acb93f7b6e4da402705d564bc235017"
47314754
integrity sha512-ol/0WzjL4NS4Kqy9VD6xXQON91xIihDT36sYCew/G/bnd1v0/4D+kahp26JauQhgFUjrdva3kRSo7URcUmQ+qw==
47324755

4756+
electron-to-chromium@^1.3.591:
4757+
version "1.3.595"
4758+
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.595.tgz#e8a9e7c6919963419f892ea981d7b3438ccb834d"
4759+
integrity sha512-JpaBIhdBkF9FLG7x06ONfe0f5bxPrxRcq0X+Sc8vsCt+OPWIzxOD+qM71NEHLGbDfN9Q6hbtHRv4/dnvcOxo6g==
4760+
47334761
elliptic@^6.5.3:
47344762
version "6.5.3"
47354763
resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.3.tgz#cb59eb2efdaf73a0bd78ccd7015a62ad6e0f93d6"
@@ -8426,7 +8454,7 @@ node-libs-browser@^2.2.1:
84268454
util "^0.11.0"
84278455
vm-browserify "^1.0.1"
84288456

8429-
node-releases@^1.1.65:
8457+
node-releases@^1.1.65, node-releases@^1.1.66:
84308458
version "1.1.66"
84318459
resolved "https://registry.yarnpkg.com/node-releases/-/node-releases-1.1.66.tgz#609bd0dc069381015cd982300bae51ab4f1b1814"
84328460
integrity sha512-JHEQ1iWPGK+38VLB2H9ef2otU4l8s3yAMt9Xf934r6+ojCYDMHPMqvCc9TnzfeFSP1QEOeU6YZEd3+De0LTCgg==
@@ -9438,13 +9466,12 @@ postcss-discard-overridden@^4.0.1:
94389466
dependencies:
94399467
postcss "^7.0.0"
94409468

9441-
postcss-import@12.0.1:
9442-
version "12.0.1"
9443-
resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-12.0.1.tgz#cf8c7ab0b5ccab5649024536e565f841928b7153"
9444-
integrity sha512-3Gti33dmCjyKBgimqGxL3vcV8w9+bsHwO5UrBawp796+jdardbcFl4RP5w/76BwNL7aGzpKstIfF9I+kdE8pTw==
9469+
postcss-import@13.0.0:
9470+
version "13.0.0"
9471+
resolved "https://registry.yarnpkg.com/postcss-import/-/postcss-import-13.0.0.tgz#d6960cd9e3de5464743b04dd8cd9d870662f8b8c"
9472+
integrity sha512-LPUbm3ytpYopwQQjqgUH4S3EM/Gb9QsaSPP/5vnoi+oKVy3/mIk2sc0Paqw7RL57GpScm9MdIMUypw2znWiBpg==
94459473
dependencies:
9446-
postcss "^7.0.1"
9447-
postcss-value-parser "^3.2.3"
9474+
postcss-value-parser "^4.0.0"
94489475
read-cache "^1.0.0"
94499476
resolve "^1.1.7"
94509477

@@ -9708,12 +9735,12 @@ postcss-url@^8.0.0:
97089735
postcss "^7.0.2"
97099736
xxhashjs "^0.2.1"
97109737

9711-
postcss-value-parser@^3.0.0, postcss-value-parser@^3.2.3:
9738+
postcss-value-parser@^3.0.0:
97129739
version "3.3.1"
97139740
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-3.3.1.tgz#9ff822547e2893213cf1c30efa51ac5fd1ba8281"
97149741
integrity sha512-pISE66AbVkp4fDQ7VHBwRNXzAAKJjw4Vw7nWI/+Q3vuly7SNfgYXvm6i5IgFylHGK5sP/xHAbB7N49OS4gWNyQ==
97159742

9716-
postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0:
9743+
postcss-value-parser@^4.0.0, postcss-value-parser@^4.0.2, postcss-value-parser@^4.1.0:
97179744
version "4.1.0"
97189745
resolved "https://registry.yarnpkg.com/postcss-value-parser/-/postcss-value-parser-4.1.0.tgz#443f6a20ced6481a2bda4fa8532a6e55d789a2cb"
97199746
integrity sha512-97DXOFbQJhk71ne5/Mt6cOu6yxsSfM0QGQyl0L25Gca4yGWEGJaig7l7gbCX623VqTBNGLRLaVUCnNkcedlRSQ==
@@ -9736,14 +9763,15 @@ postcss@7.0.21:
97369763
source-map "^0.6.1"
97379764
supports-color "^6.1.0"
97389765

9739-
postcss@7.0.32:
9740-
version "7.0.32"
9741-
resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.32.tgz#4310d6ee347053da3433db2be492883d62cec59d"
9742-
integrity sha512-03eXong5NLnNCD05xscnGKGDZ98CyzoqPSMjOe6SuoQY7Z2hIj0Ld1g/O/UQRuOle2aRtiIRDg9tDcTGAkLfKw==
9766+
postcss@8.1.7:
9767+
version "8.1.7"
9768+
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.1.7.tgz#ff6a82691bd861f3354fd9b17b2332f88171233f"
9769+
integrity sha512-llCQW1Pz4MOPwbZLmOddGM9eIJ8Bh7SZ2Oj5sxZva77uVaotYDsYTch1WBTNu7fUY0fpWp0fdt7uW40D4sRiiQ==
97439770
dependencies:
9744-
chalk "^2.4.2"
9771+
colorette "^1.2.1"
9772+
line-column "^1.0.2"
9773+
nanoid "^3.1.16"
97459774
source-map "^0.6.1"
9746-
supports-color "^6.1.0"
97479775

97489776
postcss@^8.1.4:
97499777
version "8.1.6"

0 commit comments

Comments
 (0)