-
-
Notifications
You must be signed in to change notification settings - Fork 79k
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
[DRAFT] Use postcss-drop-empty-css-vars to remove empty CSS variables #36738
base: main
Are you sure you want to change the base?
Conversation
A simple sidenote here: automating this would prevent us from using advanced usages based on the space toggle technique. I don't think Bootstrap will ever use this, but that's to be mentionned on your PostCSS plugin's Doc at least 😉 |
Might be worth opening an issue upstream in clean-css (if there isn't any already). Maybe they could implement this there too. |
Yes good idea, I need to dig into their repo. clean-css/clean-css#1180 might give some clues (+ clean-css/clean-css@a6da53a) |
I love the idea of this. I attempted to implement in Webpack but after building ( bs-btn-font-family PyCharm shows red squigglies saying "Term expected". My webpack.config.js:
My package.json
Wondering if I am doing something wrong. Apologies if this is something "a work in progress" and not yet ready to use. It seems to be exactly what I need. |
@jaradc Indeed it's something WIP, the However, if you still want to test it out with Webpack and Bootstrap, the following seems to work: https://stackblitz.com/edit/github-t4mv5h. To build it, I followed this path:
{
// Loader for webpack to process CSS with PostCSS
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
['postcss-drop-empty-css-vars', {}],
['autoprefixer', {}],
],
},
},
}, When you run the project, click on "Toggle offcanvas" and use the dev tools to check the CSS of the offcanvas, there's no empty |
Thank you Julien-Deramond for such a clear response. I did everything you said and did a text compare before/after to confirm that all 16 empty CSS variables were in-fact removed from the Webpack build. Worked for me! |
Linked to the discussion in #36597 and potentially addresses #36595.
I've tried here to create a very simple PostCSS plugin to remove empty CSS vars.
Plugin repo: https://github.com/julien-deramond/postcss-drop-empty-css-vars
Plugin code (very basic just to test the idea): https://github.com/julien-deramond/postcss-drop-empty-css-vars/blob/main/index.js
The plugin is deployed in 0.0.0 version
Running
npm run css
with and without this plugin gives this diff:/CC @mdo for thoughts