Skip to content

Commit fc5d1eb

Browse files
committed
Swap from clean-css to lightningcss, fixes #2330
1 parent b8e0418 commit fc5d1eb

3 files changed

Lines changed: 286 additions & 19 deletions

File tree

config/minification.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import CleanCSS from "clean-css";
1+
import { transform } from 'lightningcss';
2+
23
import { minify } from "terser";
34
import { readFileSync, writeFileSync, mkdirSync } from "node:fs";
45
import { parse } from "node:path";
@@ -32,12 +33,18 @@ export default function (eleventyConfig) {
3233
return `/* [11ty-website] minification skipped during dev mode */\n${code}`;
3334
});
3435

35-
eleventyConfig.addFilter("cssmin", function (code) {
36+
eleventyConfig.addFilter("cssmin", function (inputCode) {
3637
if (process.env.NODE_ENV === "production") {
37-
return new CleanCSS({}).minify(code).styles;
38+
let { code } = transform({
39+
// filename: undefined,
40+
code: Buffer.from(inputCode),
41+
minify: true,
42+
sourceMap: false
43+
});
44+
return code;
3845
}
3946

40-
return `/* [11ty-website] minification skipped during dev mode */\n${code}`;
47+
return `/* [11ty-website] minification skipped during dev mode */\n${inputCode}`;
4148
});
4249
}
4350

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
"@11ty/image-color": "^1.0.8",
5555
"@sindresorhus/slugify": "^3.0.0",
5656
"@tweetback/canonical": "^2.0.48",
57-
"clean-css": "^5.3.3",
5857
"comma-number": "^2.1.0",
5958
"degit": "^2.8.4",
6059
"dotenv": "^17.3.1",
@@ -64,6 +63,7 @@
6463
"fast-glob": "^3.3.3",
6564
"fs-extra": "^11.3.4",
6665
"human-readable-numbers": "0.9.5",
66+
"lightningcss": "^1.32.0",
6767
"lodash": "^4.18.1",
6868
"luxon": "^3.7.2",
6969
"markdown-it-table-of-contents": "^0.9.0",

0 commit comments

Comments
 (0)