Skip to content

Commit 811fc9d

Browse files
authored
Minify CSS with Lightning CSS (#25754)
Replace esbuild's rudimentary CSS minifier with [Lightning CSS](https://github.com/parcel-bundler/lightningcss), which results in around 4% smaller CSS bundle size, index.css goes from 608K to 584K. The module is quite new but has active use in the Parcel bundler, and as of yesterday is also under experimental support in Vite, so I trust it that bugs will be sorted out quickly. Before: `assets by path css/*.css 959 KiB` After: `assets by path css/*.css 933 KiB` I did give this a cursory test and everything seems to be in order.
1 parent 3780795 commit 811fc9d

File tree

3 files changed

+214
-1
lines changed

3 files changed

+214
-1
lines changed

package-lock.json

Lines changed: 210 additions & 0 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 & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"jquery.are-you-sure": "1.9.0",
3030
"katex": "0.16.8",
3131
"license-checker-webpack-plugin": "0.2.1",
32+
"lightningcss-loader": "2.1.0",
3233
"mermaid": "10.2.3",
3334
"mini-css-extract-plugin": "2.7.6",
3435
"minimatch": "9.0.2",

webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import webpack from 'webpack';
1111
import {fileURLToPath} from 'node:url';
1212
import {readFileSync} from 'node:fs';
1313
import {env} from 'node:process';
14+
import {LightningCssMinifyPlugin} from 'lightningcss-loader';
1415

1516
const {EsbuildPlugin} = EsBuildLoader;
1617
const {SourceMapDevToolPlugin, DefinePlugin} = webpack;
@@ -96,9 +97,10 @@ export default {
9697
new EsbuildPlugin({
9798
target: 'es2015',
9899
minify: true,
99-
css: true,
100+
css: false,
100101
legalComments: 'none',
101102
}),
103+
new LightningCssMinifyPlugin(),
102104
],
103105
splitChunks: {
104106
chunks: 'async',

0 commit comments

Comments
 (0)