Skip to content

Commit 218b0f8

Browse files
fix: compatibility with postcss@8 (webpack-contrib#479)
1 parent ca1389c commit 218b0f8

File tree

10 files changed

+1678
-180
lines changed

10 files changed

+1678
-180
lines changed

package-lock.json

Lines changed: 1578 additions & 162 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
],
4040
"peerDependencies": {
4141
"webpack": "^4.0.0 || ^5.0.0",
42-
"postcss": "^7.0.0"
42+
"postcss": "^7.0.0 || ^8.0.1"
4343
},
4444
"dependencies": {
4545
"cosmiconfig": "^7.0.0",
@@ -61,7 +61,7 @@
6161
"cssnano": "^4.1.10",
6262
"del": "^5.1.0",
6363
"del-cli": "^3.0.1",
64-
"eslint": "^7.8.1",
64+
"eslint": "^7.9.0",
6565
"eslint-config-prettier": "^6.11.0",
6666
"eslint-plugin-import": "^2.22.0",
6767
"husky": "^4.3.0",
@@ -72,11 +72,11 @@
7272
"memfs": "^3.2.0",
7373
"midas": "^2.0.3",
7474
"npm-run-all": "^4.1.5",
75-
"postcss": "^7.0.32",
75+
"postcss": "^8.0.1",
76+
"postcss-dark-theme-class": "^0.4.0",
7677
"postcss-import": "^12.0.1",
7778
"postcss-js": "^2.0.0",
7879
"postcss-nested": "^4.2.3",
79-
"postcss-rtl": "^1.7.3",
8080
"postcss-short": "^5.0.0",
8181
"prettier": "^2.1.1",
8282
"sass": "^1.26.10",

test/__snapshots__/postcssOptins.test.js.snap

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,15 +367,35 @@ Object {
367367
exports[`"postcssOptions" option should work with the "config" options and resolve "from" and "to" options: warnings 1`] = `Array []`;
368368

369369
exports[`"postcssOptions" option should work with the "config" options and use plugins: css 1`] = `
370-
"a { color: rgba(0, 0, 0, 1.0) }
370+
"a { color: black }
371371
372-
[dir=ltr] .foo { float: right;
372+
.foo {
373+
float: right;
373374
}
374375
375-
[dir=rtl] .foo {
376-
float: left;
376+
.bar {
377+
border-top-color: blue;
378+
border-right-color: blue;
379+
border-left-color: blue;
380+
background-color: #fafafa;
377381
}
378-
"
382+
383+
@media (prefers-color-scheme: dark) {
384+
:root:not(.is-light) { /* :root is <html> for HTML documents */
385+
--text-color: white
386+
}
387+
html:not(.is-light) body {
388+
background: black
389+
}
390+
}
391+
392+
:root.is-dark { /* :root is <html> for HTML documents */
393+
--text-color: white
394+
}
395+
396+
html.is-dark body {
397+
background: black
398+
}"
379399
`;
380400

381401
exports[`"postcssOptions" option should work with the "config" options and use plugins: errors 1`] = `Array []`;
@@ -739,13 +759,13 @@ a {
739759
}
740760
741761
.phone_title {
742-
width: 500px;
762+
width: 100px;
743763
}
744764
745765
@media (max-width: 500px) {
746766
747767
.phone_title {
748-
width: auto
768+
width: 100px
749769
}
750770
}
751771
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import style from './style.css'
2+
3+
export default style
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = function () {
2+
return {
3+
plugins: [['postcss-short', { prefix: 'x' }]],
4+
}
5+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
a { color: black }
2+
3+
.foo {
4+
float: right;
5+
}
6+
7+
.bar {
8+
-x-border-color: blue blue *;
9+
-x-color: * #fafafa;
10+
}
11+
12+
@media (prefers-color-scheme: dark) {
13+
:root { /* :root is <html> for HTML documents */
14+
--text-color: white
15+
}
16+
body {
17+
background: black
18+
}
19+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = (opts = {}) => {
2+
return {
3+
postcssPlugin: 'postcss-new-api-plugin',
4+
Declaration: {
5+
width: (node) => {
6+
node.value = '100px';
7+
},
8+
},
9+
};
10+
};
11+
module.exports.postcss = true;

test/loader.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('loader', () => {
2424
it('should throw an error on invalid syntax', async () => {
2525
const compiler = getCompiler('./css/index.js', {
2626
postcssOptions: {
27+
hideNothingWarning: true,
2728
parser: 'sugarss',
2829
},
2930
});
@@ -97,6 +98,9 @@ describe('loader', () => {
9798
},
9899
{
99100
loader: path.resolve(__dirname, '../src'),
101+
options: {
102+
postcssOptions: { hideNothingWarning: true },
103+
},
100104
},
101105
{
102106
loader: require.resolve('./helpers/astLoader'),
@@ -121,6 +125,7 @@ describe('loader', () => {
121125
const compiler = getCompiler('./sss/index.js', {
122126
postcssOptions: {
123127
parser: 'sugarss',
128+
hideNothingWarning: true,
124129
},
125130
});
126131
const stats = await compile(compiler);

test/postcssOptins.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,8 @@ describe('"postcssOptions" option', () => {
343343
require.resolve('./fixtures/plugin/other-plugin'),
344344
myPostcssPlugin({ color: 'white', alpha: 0 }),
345345
{ 'postcss-short': { prefix: 'z' } },
346+
// New API
347+
require.resolve('./fixtures/plugin/new-api.plugin'),
346348
],
347349
},
348350
});
@@ -685,10 +687,10 @@ describe('"postcssOptions" option', () => {
685687
});
686688

687689
it('should work with the "config" options and use plugins', async () => {
688-
const compiler = getCompiler('./config-scope/css/index.js', {
690+
const compiler = getCompiler('./config-scope/with-config/index.js', {
689691
postcssOptions: {
690692
config: true,
691-
plugins: ['postcss-rtl'],
693+
plugins: ['postcss-dark-theme-class'],
692694
},
693695
});
694696
const stats = await compile(compiler);

test/sourceMap.test.js

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ describe('"sourceMap" option', () => {
1919
'./css/index.js',
2020
{
2121
sourceMap: true,
22+
postcssOptions: { hideNothingWarning: true },
2223
},
2324
{
2425
devtool: false,
@@ -51,6 +52,7 @@ describe('"sourceMap" option', () => {
5152
'./css/index.js',
5253
{
5354
sourceMap: true,
55+
postcssOptions: { hideNothingWarning: true },
5456
},
5557
{
5658
devtool: 'source-map',
@@ -81,7 +83,9 @@ describe('"sourceMap" option', () => {
8183
it('should generate source maps when value is not specified and the "devtool" with "source-map" value', async () => {
8284
const compiler = getCompiler(
8385
'./css/index.js',
84-
{},
86+
{
87+
postcssOptions: { hideNothingWarning: true },
88+
},
8589
{
8690
devtool: 'source-map',
8791
}
@@ -119,6 +123,7 @@ describe('"sourceMap" option', () => {
119123
prev: false,
120124
sourcesContent: true,
121125
},
126+
hideNothingWarning: true,
122127
},
123128
},
124129
{
@@ -165,6 +170,7 @@ describe('"sourceMap" option', () => {
165170
options: {
166171
postcssOptions: {
167172
map: true,
173+
hideNothingWarning: true,
168174
},
169175
},
170176
},
@@ -228,6 +234,7 @@ describe('"sourceMap" option', () => {
228234
sourcesContent: true,
229235
annotation: true,
230236
},
237+
hideNothingWarning: true,
231238
},
232239
},
233240
},
@@ -282,6 +289,7 @@ describe('"sourceMap" option', () => {
282289
'./css/index.js',
283290
{
284291
sourceMap: false,
292+
postcssOptions: { hideNothingWarning: true },
285293
},
286294
{
287295
devtool: false,
@@ -301,6 +309,7 @@ describe('"sourceMap" option', () => {
301309
'./css/index.js',
302310
{
303311
sourceMap: false,
312+
postcssOptions: { hideNothingWarning: true },
304313
},
305314
{
306315
devtool: 'source-map',
@@ -318,7 +327,9 @@ describe('"sourceMap" option', () => {
318327
it('should not generate source maps when value is not specified and the "devtool" option with "source-map" value', async () => {
319328
const compiler = getCompiler(
320329
'./css/index.js',
321-
{},
330+
{
331+
postcssOptions: { hideNothingWarning: true },
332+
},
322333
{
323334
devtool: false,
324335
}
@@ -348,6 +359,9 @@ describe('"sourceMap" option', () => {
348359
},
349360
{
350361
loader: path.resolve(__dirname, '../src'),
362+
options: {
363+
postcssOptions: { hideNothingWarning: true },
364+
},
351365
},
352366
{
353367
loader: 'sass-loader',
@@ -387,9 +401,7 @@ describe('"sourceMap" option', () => {
387401
it('should generate source maps when previous loader returns source maps ("less-loader")', async () => {
388402
const compiler = getCompiler(
389403
'./less/index.js',
390-
{
391-
config: false,
392-
},
404+
{},
393405
{
394406
devtool: 'source-map',
395407
module: {
@@ -403,6 +415,9 @@ describe('"sourceMap" option', () => {
403415
},
404416
{
405417
loader: path.resolve(__dirname, '../src'),
418+
options: {
419+
postcssOptions: { hideNothingWarning: true },
420+
},
406421
},
407422
{
408423
loader: 'less-loader',
@@ -444,6 +459,7 @@ describe('"sourceMap" option', () => {
444459
inline: true,
445460
annotation: false,
446461
},
462+
hideNothingWarning: true,
447463
},
448464
},
449465
{
@@ -467,6 +483,7 @@ describe('"sourceMap" option', () => {
467483
inline: true,
468484
annotation: false,
469485
},
486+
hideNothingWarning: true,
470487
},
471488
},
472489
{

0 commit comments

Comments
 (0)