Use the regular preprocess-function for the CSS files as well

An old shortcoming of the `preprocessCSS`-function is its complete lack of support for our "normal" defines, which makes it very difficult to have build-specific CSS rules. Recently we've started using specially crafted comments to remove CSS rules from the MOZCENTRAL build, but (ab)using the `preprocessCSS`-function in this way really doesn't feel great.
However, it turns out to be surprisingly simple to instead use the "regular" `preprocess`-function for the CSS files as well. The only special-handling that's still necessary is the helper-function for dealing with CSS-imports, but apart from that everything seems to just work.

One reason, as far as I can tell, for having a separate `preprocessCSS`-function was likely that we originally used *lots* of vendor-prefixed CSS rules in our CSS files. With improvements over the years, especially thanks to Autoprefixer and PostCSS, we've been able to remove *almost* all non-standard CSS rules and the need for special-casing the CSS parsing has mostly vanished.

*Please note:* As part of testing this patch I've diffed the output of `gulp generic`, `gulp mozcentral`, and `gulp chromium` against the `master`-branch to check that there was no obvious breakage.
This commit is contained in:
Jonas Jenwald 2022-05-07 22:00:54 +02:00
parent f8838eb794
commit d1f13a6af3
5 changed files with 61 additions and 91 deletions

View file

@ -816,7 +816,7 @@ gulp.task("cmaps", function (done) {
function preprocessCSS(source, defines) {
const outName = getTempFile("~preprocess", ".css");
builder.preprocessCSS(source, outName, defines);
builder.preprocess(source, outName, defines);
let out = fs.readFileSync(outName).toString();
fs.unlinkSync(outName);