Skip to content

Commit e094fa6

Browse files
authored
Merge pull request #169 from TrySound/upgrade-postcss
upgrade postcss
2 parents 1d53d32 + 033fcbd commit e094fa6

File tree

3 files changed

+47
-85
lines changed

3 files changed

+47
-85
lines changed

packages/resolve-url-loader/lib/engine/postcss.js

+21-28
Original file line numberDiff line numberDiff line change
@@ -28,37 +28,12 @@ function process(sourceFile, sourceContent, params) {
2828
sourceContent.replace(ORPHAN_CR_REGEX, ' $1') :
2929
sourceContent;
3030

31-
// prepend file protocol to all sources to avoid problems with source map
32-
return postcss([
33-
postcss.plugin('postcss-resolve-url', postcssPlugin)
34-
])
35-
.process(correctedContent, {
36-
from: fileProtocol.prepend(sourceFile),
37-
map : params.outputSourceMap && {
38-
prev : !!params.absSourceMap && fileProtocol.prepend(params.absSourceMap),
39-
inline : false,
40-
annotation : false,
41-
sourcesContent: true // #98 sourcesContent missing from output map
42-
}
43-
})
44-
.then(result => ({
45-
content: result.css,
46-
map : params.outputSourceMap ? fileProtocol.remove(result.map.toJSON()) : null
47-
}));
48-
4931
/**
5032
* Plugin for postcss that follows SASS transpilation.
5133
*/
52-
function postcssPlugin() {
53-
return function applyPlugin(styles) {
54-
styles.walkDecls(eachDeclaration);
55-
};
56-
57-
/**
58-
* Process a declaration from the syntax tree.
59-
* @param declaration
60-
*/
61-
function eachDeclaration(declaration) {
34+
const postcssPlugin = {
35+
postcssPlugin: 'postcss-resolve-url',
36+
Declaration: (declaration) => {
6237
var prefix,
6338
isValid = declaration.value && (declaration.value.indexOf('url') >= 0);
6439
if (isValid) {
@@ -105,6 +80,24 @@ function process(sourceFile, sourceContent, params) {
10580
}
10681
}
10782

83+
// prepend file protocol to all sources to avoid problems with source map
84+
return postcss([
85+
postcssPlugin
86+
])
87+
.process(correctedContent, {
88+
from: fileProtocol.prepend(sourceFile),
89+
map : params.outputSourceMap && {
90+
prev : !!params.absSourceMap && fileProtocol.prepend(params.absSourceMap),
91+
inline : false,
92+
annotation : false,
93+
sourcesContent: true // #98 sourcesContent missing from output map
94+
}
95+
})
96+
.then(result => ({
97+
content: result.css,
98+
map : params.outputSourceMap ? fileProtocol.remove(result.map.toJSON()) : null
99+
}));
100+
108101
/**
109102
* Given an apparent position find the directory of the original file.
110103
*

packages/resolve-url-loader/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"homepage": "https://github.com/bholloway/resolve-url-loader/tree/v4-maintenance/packages/resolve-url-loader",
2929
"engines": {
30-
"node": ">=8.9"
30+
"node": "^10 || ^12 || >=14"
3131
},
3232
"files": [
3333
"index.js",
@@ -38,7 +38,7 @@
3838
"adjust-sourcemap-loader": "^4.0.0",
3939
"convert-source-map": "^1.7.0",
4040
"loader-utils": "^2.0.0",
41-
"postcss": "^7.0.35",
41+
"postcss": "^8.1.9",
4242
"source-map": "0.6.1"
4343
},
4444
"peerDependencies": {

yarn.lock

+24-55
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,6 @@ ansi-styles@^2.2.1:
4949
resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"
5050
integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=
5151

52-
ansi-styles@^3.2.1:
53-
version "3.2.1"
54-
resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d"
55-
integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==
56-
dependencies:
57-
color-convert "^1.9.0"
58-
5952
argparse@^1.0.7:
6053
version "1.0.10"
6154
resolved "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
@@ -130,15 +123,6 @@ chalk@^1.1.1:
130123
strip-ansi "^3.0.0"
131124
supports-color "^2.0.0"
132125

133-
chalk@^2.4.2:
134-
version "2.4.2"
135-
resolved "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424"
136-
integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==
137-
dependencies:
138-
ansi-styles "^3.2.1"
139-
escape-string-regexp "^1.0.5"
140-
supports-color "^5.3.0"
141-
142126
cli@~1.0.0:
143127
version "1.0.1"
144128
resolved "https://registry.npmjs.org/cli/-/cli-1.0.1.tgz#22817534f24bfa4950c34d532d48ecbc621b8c14"
@@ -147,17 +131,10 @@ cli@~1.0.0:
147131
exit "0.1.2"
148132
glob "^7.1.1"
149133

150-
color-convert@^1.9.0:
151-
version "1.9.3"
152-
resolved "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8"
153-
integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==
154-
dependencies:
155-
color-name "1.1.3"
156-
157-
158-
version "1.1.3"
159-
resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25"
160-
integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=
134+
colorette@^1.2.1:
135+
version "1.2.1"
136+
resolved "https://registry.npmjs.org/colorette/-/colorette-1.2.1.tgz#4d0b921325c14faf92633086a536db6e89564b1b"
137+
integrity sha512-puCDz0CzydiSYOrnXpz/PKd69zRrribezjtE9yd4zvytoRc8+RY/KJPvtPFKZS3E3wP6neGyMe0vOTlHO5L3Pw==
161138

162139
compose-function@^3.0.3:
163140
version "3.0.3"
@@ -464,11 +441,6 @@ has-ansi@^2.0.0:
464441
dependencies:
465442
ansi-regex "^2.0.0"
466443

467-
has-flag@^3.0.0:
468-
version "3.0.0"
469-
resolved "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd"
470-
integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0=
471-
472444
has-flag@^4.0.0:
473445
version "4.0.0"
474446
resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
@@ -639,9 +611,9 @@ json5@^2.1.2:
639611
minimist "^1.2.5"
640612

641613
just-extend@^4.0.2:
642-
version "4.1.1"
643-
resolved "https://registry.npmjs.org/just-extend/-/just-extend-4.1.1.tgz#158f1fdb01f128c411dc8b286a7b4837b3545282"
644-
integrity sha512-aWgeGFW67BP3e5181Ep1Fv2v8z//iBJfrvyTnq8wG86vEESwmonn1zPBJ0VfmT9CJq2FIT0VsETtrNFm2a+SHA==
614+
version "4.1.0"
615+
resolved "https://registry.npmjs.org/just-extend/-/just-extend-4.1.0.tgz#7278a4027d889601640ee0ce0e5a00b992467da4"
616+
integrity sha512-ApcjaOdVTJ7y4r08xI5wIqpvwS48Q0PBG4DJROcEkH1f8MdAiNFyFxz3xoL0LWAVwjrwPYZdVHHxhRHcx/uGLA==
645617

646618
loader-utils@^2.0.0:
647619
version "2.0.0"
@@ -706,6 +678,11 @@ ms@^2.1.2:
706678
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
707679
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
708680

681+
nanoid@^3.1.18:
682+
version "3.1.18"
683+
resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.1.18.tgz#0680db22ab01c372e89209f5d18283d98de3e96d"
684+
integrity sha512-rndlDjbbHbcV3xi+R2fpJ+PbGMdfBxz5v1fATIQFq0DP64FsicQdwnKLy47K4kZHdRpmQXtz24eGsxQqamzYTA==
685+
709686
nise@^3.0.1:
710687
version "3.0.1"
711688
resolved "https://registry.npmjs.org/nise/-/nise-3.0.1.tgz#0659982af515e5aac15592226246243e8da0013d"
@@ -818,14 +795,15 @@ plur@^1.0.0:
818795
resolved "https://registry.npmjs.org/plur/-/plur-1.0.0.tgz#db85c6814f5e5e5a3b49efc28d604fec62975156"
819796
integrity sha1-24XGgU9eXlo7Se/CjWBP7GKXUVY=
820797

821-
postcss@^7.0.35:
822-
version "7.0.35"
823-
resolved "https://registry.npmjs.org/postcss/-/postcss-7.0.35.tgz#d2be00b998f7f211d8a276974079f2e92b970e24"
824-
integrity sha512-3QT8bBJeX/S5zKTTjTCIjRF3If4avAT6kqxcASlTWEtAFCb9NH0OUxNDfgZSWdP5fJnBYCMEWkIFfWeugjzYMg==
798+
postcss@^8.1.9:
799+
version "8.1.9"
800+
resolved "https://registry.npmjs.org/postcss/-/postcss-8.1.9.tgz#20ff4b598a6f5015c5f7fe524b8ed5313d7ecade"
801+
integrity sha512-oWuBpEl1meaMKkQXn0ic78TUrgsMvrAZLE/6ZY0H3LTteq2O3L8PGWwMbPLctpksTJIHjQeossMUMNQW7qRIHQ==
825802
dependencies:
826-
chalk "^2.4.2"
803+
colorette "^1.2.1"
804+
nanoid "^3.1.18"
827805
source-map "^0.6.1"
828-
supports-color "^6.1.0"
806+
vfile-location "^3.2.0"
829807

830808
pretty-ms@^2.1.0:
831809
version "2.1.0"
@@ -1053,20 +1031,6 @@ supports-color@^2.0.0:
10531031
resolved "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"
10541032
integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=
10551033

1056-
supports-color@^5.3.0:
1057-
version "5.5.0"
1058-
resolved "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f"
1059-
integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==
1060-
dependencies:
1061-
has-flag "^3.0.0"
1062-
1063-
supports-color@^6.1.0:
1064-
version "6.1.0"
1065-
resolved "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3"
1066-
integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==
1067-
dependencies:
1068-
has-flag "^3.0.0"
1069-
10701034
supports-color@^7.1.0:
10711035
version "7.2.0"
10721036
resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
@@ -1161,6 +1125,11 @@ util-deprecate@~1.0.1:
11611125
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
11621126
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
11631127

1128+
vfile-location@^3.2.0:
1129+
version "3.2.0"
1130+
resolved "https://registry.npmjs.org/vfile-location/-/vfile-location-3.2.0.tgz#d8e41fbcbd406063669ebf6c33d56ae8721d0f3c"
1131+
integrity sha512-aLEIZKv/oxuCDZ8lkJGhuhztf/BW4M+iHdCwglA/eWc+vtuRFJj8EtgceYFX4LRjOhCAAiNHsKGssC6onJ+jbA==
1132+
11641133
vlq@^1.0.1:
11651134
version "1.0.1"
11661135
resolved "https://registry.npmjs.org/vlq/-/vlq-1.0.1.tgz#c003f6e7c0b4c1edd623fd6ee50bbc0d6a1de468"

0 commit comments

Comments
 (0)