All Projects → navanshu → postcss-variable-compress

navanshu / postcss-variable-compress

Licence: MIT license
Minifies css variable names

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to postcss-variable-compress

fylgja
The modular highly customisable CSS framework. Powered by CSS Components, Utilities and Props for building your Web UI.
Stars: ✭ 65 (+261.11%)
Mutual labels:  postcss, css-custom-properties, css-variables
Halfmoon
Front-end framework with a built-in dark mode and full customizability using CSS variables; great for building dashboards and tools.
Stars: ✭ 2,583 (+14250%)
Mutual labels:  css-custom-properties, css-variables
React Native Css Modules
Style React Native components using CSS, PostCSS, Sass, Less or Stylus.
Stars: ✭ 207 (+1050%)
Mutual labels:  postcss, css-variables
theme-change
Change CSS theme with toggle, buttons or select using CSS custom properties and localStorage
Stars: ✭ 283 (+1472.22%)
Mutual labels:  css-custom-properties, css-variables
Core
Native HTML Elements with CSS superpowers. 🕶
Stars: ✭ 237 (+1216.67%)
Mutual labels:  postcss, css-variables
v-helper
A shorter SCSS access to CSS custom properties.
Stars: ✭ 14 (-22.22%)
Mutual labels:  css-custom-properties, css-variables
multi-brand-colors
Multi Brand Colors with support for CSS/CSS-Vars/SCSS/SASS/Stylus/LESS/JSON
Stars: ✭ 26 (+44.44%)
Mutual labels:  postcss, css-variables
postcss-styled
PostCSS syntax for parsing styled components
Stars: ✭ 53 (+194.44%)
Mutual labels:  postcss
vite-plugin-sleep
a vite plugin you never need. slow devServer and slow HMR.
Stars: ✭ 77 (+327.78%)
Mutual labels:  vite-plugin
criteria-of-quality-frontend
Критерии качественной вёрстки (разметка, стилизация, картинки, шрифты, автоматизация и пр.)
Stars: ✭ 26 (+44.44%)
Mutual labels:  postcss
postcss-prefixwrap
A PostCSS plugin that is used to wrap css styles with a css selector to constrain their affect on parent elements in a page.
Stars: ✭ 54 (+200%)
Mutual labels:  postcss
Lexical.FileSystem
Virtual IFileSystem interfaces, and implementations.
Stars: ✭ 24 (+33.33%)
Mutual labels:  abstraction
postcss-flexible
🔲 dpr/rem/url transformer for flexible
Stars: ✭ 19 (+5.56%)
Mutual labels:  postcss
vite-plugin-webfont-dl
⚡ Webfont Download Vite Plugin - Make your Vite site load faster
Stars: ✭ 69 (+283.33%)
Mutual labels:  vite-plugin
postcss-font-pack
PostCSS plugin to simplify font declarations by validating only configured font packs are used and adding fallbacks.
Stars: ✭ 18 (+0%)
Mutual labels:  postcss
focussed-twitter
Let's focus on the tweets! 🐦
Stars: ✭ 15 (-16.67%)
Mutual labels:  css-variables
postcsslayouts
This is the repository for my course, Building a Responsive Single-Page Design with PostCSS on LinkedIn Learning and Lynda.com.
Stars: ✭ 22 (+22.22%)
Mutual labels:  postcss
nest-abstract
NestJs Abstraction Helper
Stars: ✭ 36 (+100%)
Mutual labels:  abstraction
injected-css
{:;} CSS in JS
Stars: ✭ 18 (+0%)
Mutual labels:  postcss
bootstrap-shopify-theme
🛍 A free Shopify Theme built with Bootstrap, BEM, Liquid, Sass, ESNext, Theme Tools, ... and Webpack.
Stars: ✭ 41 (+127.78%)
Mutual labels:  postcss

PostCSS Variable Compress npm GitHub branch checks state

postcss-variable-compress is a PostCSS plugin minifies variable names and saves space. Even if you have 1295 css variables still they will not exceed by two characters. It will transform css variable without breaking your stylesheet.

If you want it not modify some css variables, then pass them --{variable-name} as an array to the plugin.

If you are looking for a plugin that can work on separate files go to import splitFiles.js, works the same but it doesn't resets the variables.

:root {
  --first-color: #16f;
  --second-color: #ff7;
}

#firstParagraph {
  background-color: var(--first-color);
  color: var(--second-color);
}

#container {
  --first-color: #290;
}
:root {
  --0: #16f;
  --1: #ff7;
}

#firstParagraph {
  background-color: var(--0);
  color: var(--1);
}

#container {
  --0: #290;
}

Usage

Step 1: Install plugin:

npm install --save-dev postcss postcss-variable-compress

Step 2: Check you project for existed PostCSS config: postcss.config.js in the project root, "postcss" section in package.json or postcss in bundle config.

If you do not use PostCSS, add it according to official docs and set this plugin in settings.

Step 3: Add the plugin at the end of the plugins list:

module.exports = {
  plugins: [
    require('cssnano'),
+   require('postcss-variable-compress')
  ]
}

Api

module.exports = {
  plugins: [
    require('cssnano'),
    require('postcss-variable-compress')(
      // pass in css variables to avoid
      'light', 'dark', 'font', 'vh', 'r' // unprefixed
      // or
      '--height', '--font' // prefixed
      // or pass in as many function as your want
      // they take single param which is a the name of css variable
      // you can do checks on it and
      // return true if you want it to be skipped
      // for example
      (name) => name.includes('skip') // name prefixed css variable example --height
      // avoid regex if you can they are bad
    )
  ]
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].