JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 104827
  • Score
    100M100P100Q168941F
  • License CC0-1.0

PostCSS plugin that enables Sass-like variables, conditionals, and iterators in CSS

Package Exports

  • postcss-advanced-variables

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (postcss-advanced-variables) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

PostCSS Advanced Variables Build Status

PostCSS Advanced Variables is a PostCSS plugin that converts Sass variables and conditionals into CSS.

/* before */

$dir: assets/icons;

@each $icon in (foo, bar, baz) {
    .icon-$icon {
        background: url('$dir/$icon.png');
    }
}

@for $index from 1 to 5 by 2 {
    .col-$index {
        width: $(index)0%;
    }
}

/* after */

.icon-foo {
    background: url('assets/icons/foo.png');
}

.icon-bar {
    background: url('assets/icons/bar.png');
}

.icon-baz {
    background: url('assets/icons/baz.png');
}

.col-1 {
    width: 10%;
}

.col-3 {
    width: 30%;
}

.col-5 {
    width: 50%;
}

Usage

You just need to follow these two steps to use PostCSS Advanced Variables:

  1. Add PostCSS to your build tool.
  2. Add PostCSS Advanced Variables as a PostCSS process.
npm install postcss-advanced-variables --save-dev

Node

postcss([ require('postcss-advanced-variables')({ /* options */ }) ])

Grunt

Add [Grunt PostCSS] to your build tool:

npm install postcss-advanced-variables --save-dev

Enable PostCSS Advanced Variables within your Gruntfile:

grunt.loadNpmTasks('grunt-postcss');

grunt.initConfig({
    postcss: {
        options: {
            processors: [
                require('postcss-advanced-variables')({ /* options */ })
            ]
        },
        dist: {
            src: 'css/*.css'
        }
    }
});