Skip to content

Commit 0f32344

Browse files
authored
eng: allow css nesting via postcss plugin (microsoft#203726)
* eng: allow css nesting via postcss plugin CSS nesting has landed in most browsers at this point, but we don't want to break users who are still stuck on old browser (mainly older iOS devices.) This PR adds a postcss plugin to the build process that de-nests nested CSS. The plugin required a newer version of postcss as well, so I have updated that and a couple other modules to their latest versions. * update build's package.json versions too
1 parent c9555f6 commit 0f32344

File tree

7 files changed

+464
-724
lines changed

7 files changed

+464
-724
lines changed

build/lib/compilation.js

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

build/lib/compilation.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,17 @@ function createCompile(src: string, build: boolean, emitError: boolean, transpil
6464
const tsFilter = util.filter(data => /\.ts$/.test(data.path));
6565
const isUtf8Test = (f: File) => /(\/|\\)test(\/|\\).*utf8/.test(f.path);
6666
const isRuntimeJs = (f: File) => f.path.endsWith('.js') && !f.path.includes('fixtures');
67+
const isCSS = (f: File) => f.path.endsWith('.css') && !f.path.includes('fixtures');
6768
const noDeclarationsFilter = util.filter(data => !(/\.d\.ts$/.test(data.path)));
6869

70+
const postcss = require('gulp-postcss') as typeof import('gulp-postcss');
71+
const postcssNesting = require('postcss-nesting');
72+
6973
const input = es.through();
7074
const output = input
7175
.pipe(util.$if(isUtf8Test, bom())) // this is required to preserve BOM in test files that loose it otherwise
7276
.pipe(util.$if(!build && isRuntimeJs, util.appendOwnPathSourceURL()))
77+
.pipe(util.$if(isCSS, postcss([postcssNesting()])))
7378
.pipe(tsFilter)
7479
.pipe(util.loadSourcemaps())
7580
.pipe(compilation(token))

build/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
"@electron/get": "^2.0.0",
1010
"@types/ansi-colors": "^3.2.0",
1111
"@types/byline": "^4.2.32",
12-
"@types/cssnano": "^4.0.0",
1312
"@types/debounce": "^1.0.0",
1413
"@types/debug": "^4.1.5",
1514
"@types/fancy-log": "^1.3.0",
@@ -20,7 +19,7 @@
2019
"@types/gulp-filter": "^3.0.32",
2120
"@types/gulp-gzip": "^0.0.31",
2221
"@types/gulp-json-editor": "^2.2.31",
23-
"@types/gulp-postcss": "^8.0.0",
22+
"@types/gulp-postcss": "^8.0.6",
2423
"@types/gulp-rename": "^0.0.33",
2524
"@types/gulp-sourcemaps": "^0.0.32",
2625
"@types/mime": "0.0.29",

build/yarn.lock

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -407,13 +407,6 @@
407407
"@types/events" "*"
408408
"@types/node" "*"
409409

410-
"@types/cssnano@^4.0.0":
411-
version "4.0.1"
412-
resolved "https://registry.yarnpkg.com/@types/cssnano/-/cssnano-4.0.1.tgz#67fa912753d80973a016e7684a47fedf338aacff"
413-
integrity sha512-hGOroxRTBkYl5gSBRJOffhV4+io+Y2bFX1VP7LgKEVHJt/LPPJaWUIuDAz74Vlp7l7hCDZfaDi7iPxwNwuVA4Q==
414-
dependencies:
415-
postcss "5 - 7"
416-
417410
"@types/debounce@^1.0.0":
418411
version "1.0.0"
419412
resolved "https://registry.yarnpkg.com/@types/debounce/-/debounce-1.0.0.tgz#417560200331e1bb84d72da85391102c2fcd61b7"
@@ -491,10 +484,10 @@
491484
"@types/js-beautify" "*"
492485
"@types/node" "*"
493486

494-
"@types/gulp-postcss@^8.0.0":
495-
version "8.0.0"
496-
resolved "https://registry.yarnpkg.com/@types/gulp-postcss/-/gulp-postcss-8.0.0.tgz#f7e86d45e4999fd43e6d8c55b00504c88a67ad61"
497-
integrity sha512-AVgjA03bpkYONKZpzuJviB9PzaNbDzrovYPbenj8/XxivUc35C/dIzJanyaQv7CFqfLLPLsqSalmtP3GLq6iag==
487+
"@types/gulp-postcss@^8.0.6":
488+
version "8.0.6"
489+
resolved "https://registry.yarnpkg.com/@types/gulp-postcss/-/gulp-postcss-8.0.6.tgz#d314c785876c8a1779154ba1d152125082ecde0f"
490+
integrity sha512-mjGEmTvurqRHFeJQnrgtMC9GtKNkI2+56n92zIzff5UFr2jUfilw1elKRxS7bK0FYRvuEcnMX9JH0AUpCxBrpg==
498491
dependencies:
499492
"@types/node" "*"
500493
"@types/vinyl" "*"
@@ -2201,15 +2194,6 @@ [email protected], plugin-error@^1.0.1:
22012194
arr-union "^3.1.0"
22022195
extend-shallow "^3.0.2"
22032196

2204-
"postcss@5 - 7":
2205-
version "7.0.36"
2206-
resolved "https://registry.yarnpkg.com/postcss/-/postcss-7.0.36.tgz#056f8cffa939662a8f5905950c07d5285644dfcb"
2207-
integrity sha512-BebJSIUMwJHRH0HAQoxN4u1CN86glsrwsW0q7T+/m44eXOUAxSNdHRkNZPYz5vVUbg17hFgOQDE7fZk7li3pZw==
2208-
dependencies:
2209-
chalk "^2.4.2"
2210-
source-map "^0.6.1"
2211-
supports-color "^6.1.0"
2212-
22132197
prebuild-install@^7.0.1, prebuild-install@^7.1.1:
22142198
version "7.1.1"
22152199
resolved "https://registry.yarnpkg.com/prebuild-install/-/prebuild-install-7.1.1.tgz#de97d5b34a70a0c81334fd24641f2a1702352e45"
@@ -2439,7 +2423,7 @@ simple-get@^4.0.0:
24392423
once "^1.3.1"
24402424
simple-concat "^1.0.0"
24412425

2442-
[email protected], source-map@^0.6.1:
2426+
24432427
version "0.6.1"
24442428
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
24452429
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
@@ -2514,13 +2498,6 @@ supports-color@^5.3.0:
25142498
dependencies:
25152499
has-flag "^3.0.0"
25162500

2517-
supports-color@^6.1.0:
2518-
version "6.1.0"
2519-
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3"
2520-
integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ==
2521-
dependencies:
2522-
has-flag "^3.0.0"
2523-
25242501
supports-color@^7.1.0:
25252502
version "7.2.0"
25262503
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@
110110
"@playwright/test": "^1.40.1",
111111
"@swc/core": "1.3.62",
112112
"@types/cookie": "^0.3.3",
113-
"@types/cssnano": "^4.0.0",
114113
"@types/debug": "^4.1.5",
115114
"@types/graceful-fs": "4.1.2",
116-
"@types/gulp-postcss": "^8.0.0",
115+
"@types/gulp-postcss": "^8.0.6",
117116
"@types/gulp-svgmin": "^1.2.1",
118117
"@types/http-proxy-agent": "^2.0.1",
119118
"@types/kerberos": "^1.1.2",
@@ -146,8 +145,8 @@
146145
"chromium-pickle-js": "^0.2.0",
147146
"cookie": "^0.4.0",
148147
"copy-webpack-plugin": "^11.0.0",
149-
"css-loader": "^6.7.3",
150-
"cssnano": "^4.1.11",
148+
"css-loader": "^6.9.1",
149+
"cssnano": "^6.0.3",
151150
"debounce": "^1.0.0",
152151
"deemon": "^1.8.0",
153152
"electron": "27.2.3",
@@ -171,7 +170,7 @@
171170
"gulp-gzip": "^1.4.2",
172171
"gulp-json-editor": "^2.5.0",
173172
"gulp-plumber": "^1.2.0",
174-
"gulp-postcss": "^9.0.0",
173+
"gulp-postcss": "^9.1.0",
175174
"gulp-rename": "^1.2.0",
176175
"gulp-replace": "^0.5.4",
177176
"gulp-sourcemaps": "^3.0.0",
@@ -197,6 +196,8 @@
197196
"opn": "^6.0.0",
198197
"p-all": "^1.0.0",
199198
"path-browserify": "^1.0.1",
199+
"postcss": "^8.4.33",
200+
"postcss-nesting": "^12.0.2",
200201
"pump": "^1.0.1",
201202
"rcedit": "^1.1.0",
202203
"rimraf": "^2.2.8",

src/vs/workbench/contrib/testing/browser/media/testing.css

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,30 @@
55

66
/** -- icons */
77

8-
.monaco-workbench .codicon-testing-error-icon {
9-
color: var(--vscode-testing-iconErrored);
10-
}
11-
12-
.monaco-workbench .codicon-testing-failed-icon {
13-
color: var(--vscode-testing-iconFailed);
14-
}
15-
16-
.monaco-workbench .codicon-testing-passed-icon {
17-
color: var(--vscode-testing-iconPassed);
18-
}
19-
20-
.monaco-workbench .codicon-testing-queued-icon {
21-
color: var(--vscode-testing-iconQueued);
22-
}
23-
24-
.monaco-workbench .codicon-testing-skipped-icon {
25-
color: var(--vscode-testing-iconSkipped);
26-
}
27-
28-
.monaco-workbench .codicon-testing-unset-icon {
29-
color: var(--vscode-testing-iconUnset);
8+
.monaco-workbench {
9+
.codicon-testing-error-icon {
10+
color: var(--vscode-testing-iconErrored);
11+
}
12+
13+
.codicon-testing-failed-icon {
14+
color: var(--vscode-testing-iconFailed);
15+
}
16+
17+
.codicon-testing-passed-icon {
18+
color: var(--vscode-testing-iconPassed);
19+
}
20+
21+
.codicon-testing-queued-icon {
22+
color: var(--vscode-testing-iconQueued);
23+
}
24+
25+
.codicon-testing-skipped-icon {
26+
color: var(--vscode-testing-iconSkipped);
27+
}
28+
29+
.codicon-testing-unset-icon {
30+
color: var(--vscode-testing-iconUnset);
31+
}
3032
}
3133

3234
/** -- explorer */

0 commit comments

Comments
 (0)