Use postcss-custom-properties to statically represent CSS3 variables on build-time
See original GitHub issueFeature request
Is your feature request related to a problem? Please describe. CSS3 variables are great! We can avoid using a preprocessor while still doing enough to avoid hard-coding stuff in a CSS Module system. One problem is that CSS3 variables don’t have the best browser support.
Describe the solution you’d like
We can use postcss-css-variables to statically extract variables on build-time! Add the dependency and integrate it within postcss.config.js
. Please uncomment env
within postcss.config.js
and only leverage library when env === 'production'
(see here for more on ctx).
/* eslint-disable global-require */
module.exports = ({ file, options, env }) => {
const ENV = env.toLowerCase();
const isProd = ENV === 'production';
return {
...options,
plugins: [
require('postcss-import')({ root: file.dirname }),
isProd ? require('postcss-css-variables')() : false,
require('autoprefixer')()
],
};
};
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (9 by maintainers)
Top Results From Across the Web
postcss/postcss-custom-properties - GitHub
PostCSS Custom Properties lets you use Custom Properties in CSS, following the CSS Custom Properties specification. 'Can I use' table. :root { --color:...
Read more >CSS custom properties (native variables) In-Depth
PostCSS plugin to transform W3C CSS Custom Properties- a simple plugin which processes only variables declared for :root · PostCSS plugin to ...
Read more >CSS Variables Are A Sometimes Food | by Matt Stow | Medium
Although using PostCSS for CSS variables is “spec-compliant”, since they aren't backwards compatible, you'll currently need to convert them ...
Read more >postcss-custom-properties - npm
Use Custom Properties Queries in CSS. ... Start using postcss-custom-properties in your project by running `npm i postcss-custom-properties` ...
Read more >CSSNEXT: how to use variables with media queries in CSS Next
cssnext only implements future-proof specifications. And per specification, it's not possible to use custom properties (that' depends on the dom (:root is ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am assigning myself to this issue as a placeholder for your work, @TomerPacific. Thank you, and good luck! 😁
Please note: If no activity is shared within two weeks, I will remove my assignment. At that point, the issue will be open for anybody to take.
Assigning myself for @juliantrueflynn