Skip to content

Instantly share code, notes, and snippets.

@rfviolato
Last active February 2, 2017 00:20
Show Gist options
  • Save rfviolato/2ce47ca46ac58ee01464db2803c3f5a8 to your computer and use it in GitHub Desktop.
Save rfviolato/2ce47ca46ac58ee01464db2803c3f5a8 to your computer and use it in GitHub Desktop.
CSSNext Vars
/* No imports needed */
.nav {
width: var(--Nav-mobile-height);
}
import cssVariables from './variables.js';
const myCssVar = cssVariables['--Nav-mobile-height'];
export default {
'--Nav-mobile-height': '80px',
(...your other variables)
};
import cssVariables from './variables.js';
const config = {};
(...other webpack config stuff)
config.postcss = () => ([
cssnext({
features: {
customProperties: {
variables: cssVariables,
},
},
}),
(...other plugins)
]);
export default config;
@RafalFilipek
Copy link

Nice!

According to docs you don't have to prefix vars with --.

The keys are automatically prefixed with the CSS -- to make it easier to share variables in your codebase.

https://github.com/postcss/postcss-custom-properties#variables

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment