eng: allow css nesting via postcss plugin (#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
This commit is contained in:
Connor Peet
2024-01-29 11:19:37 -08:00
committed by GitHub
parent c9555f641b
commit 0f323440e5
7 changed files with 473 additions and 733 deletions
+4
View File
@@ -55,11 +55,15 @@ function createCompile(src, build, emitError, transpileOnly) {
const tsFilter = util.filter(data => /\.ts$/.test(data.path));
const isUtf8Test = (f) => /(\/|\\)test(\/|\\).*utf8/.test(f.path);
const isRuntimeJs = (f) => f.path.endsWith('.js') && !f.path.includes('fixtures');
const isCSS = (f) => f.path.endsWith('.css') && !f.path.includes('fixtures');
const noDeclarationsFilter = util.filter(data => !(/\.d\.ts$/.test(data.path)));
const postcss = require('gulp-postcss');
const postcssNesting = require('postcss-nesting');
const input = es.through();
const output = input
.pipe(util.$if(isUtf8Test, bom())) // this is required to preserve BOM in test files that loose it otherwise
.pipe(util.$if(!build && isRuntimeJs, util.appendOwnPathSourceURL()))
.pipe(util.$if(isCSS, postcss([postcssNesting()])))
.pipe(tsFilter)
.pipe(util.loadSourcemaps())
.pipe(compilation(token))