-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to Lightning CSS #18177
Switch to Lightning CSS #18177
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general when comparing for something like this, it would be useful to know the impact on the whole bundle:
du --apparent-size --total -h hass_frontend/frontend_latest/*.js
du --apparent-size --total -h hass_frontend/frontend_es5/*.js
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
build-scripts/bundle.cjs
Outdated
compatibility: "*,-properties.zeroUnits", | ||
minifyCSS: (text, type) => { | ||
const input = wrapCSS(text, type); | ||
const { code } = lightningcss.transform({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also collect the warnings array here from output, and log them if not empty
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I get warnings about Unsupported pseudo class or element: b2lopmc8akq
whenever someone uses a variable inside of a css template literal, because one of the plugins replaces all variables with things like babel-plugin-template-html-minifier:b2lopmc8akq
. I also get some warnings like "unknown rule @apply" wherever we use that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That plugin is what's running html-minifier-terser
on all the tagged templates. For debugging (if you already haven't), do dev builds with:
- Comment out the
isProdBuild &&
in front of that plugin in the Babel options - Change the
devTool
setting inwebpack.cjs
to get rid ofeval-
After that, it should be much easier to find and inspect various templates to see what's happening. Wherever there are substitutions, technically there should be nothing but numbers or other CSS templates because that's all lit allows without unsafeCSS
.
For @apply
, I think you can add exceptions in the settings?
Oddly, while Lightning CSS is better in most cases (including the entrypoint files), it's producing a ~20kb bigger total output even when no targets are specified. |
878e279
to
919d224
Compare
FYI to anyone else building this, I recently found out that you may need to do |
That's probably the |
Turns out that in a number of cases, LCSS doesn't do certain optimizations, which is why its bundle is larger:
I'm going to leave this PR as a draft because I opened issues for those things in LCSS's repo. While I could do something like minifying with both CCSS and LCSS, that seems unwise. |
919d224
to
e212e97
Compare
Actually no. Something really weird is going on - while LCSS is worse in some cases, the total bundle should be 25kb smaller (according to tallying within the parsecss function), not 20kb bigger. |
4b158de
to
6a37e22
Compare
Closing as it's unlikely that my concerns will be addressed, and I can always recreate the PR later if they are |
Proposed change
Some bundles go up, because LCSS doesn't do some minifications, plus we started doing prefixing
Currently a draft because I'm waiting for the LCSS team to respond to one of my issues to prove that the repo is active
Type of change
Additional information
N/A
Checklist