question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use postcss-custom-properties to statically represent CSS3 variables on build-time

See original GitHub issue

Feature 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:closed
  • Created 5 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
kylemhcommented, Nov 27, 2018

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.

0reactions
kylemhcommented, Feb 23, 2019

Assigning myself for @juliantrueflynn

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found