postcss-custom-unit

PostCSS plugin custom unit

Usage no npm install needed!

<script type="module">
  import postcssCustomUnit from 'https://cdn.skypack.dev/postcss-custom-unit';
</script>

README

PostCSS Custom Unit Build Status

PostCSS plugin custom unit, custom convert function.

.foo {
    width: 100munit;
    padding: 100munit 200munit;
}
.foo {
    width: 200rem;
    padding: 200rem 400rem;
}

Usage

postcss([ require('postcss-custom-unit') ])

See PostCSS docs for examples for your environment.

Option

  • includePath custom include path
  • units custom unit and convert function
var customUnit = require("postcss-custom-unit")

module.exports = ctx => ({
    plugins: [
        customUnit({
            includePath: /xxxx/,
            units: [{ from: 'munit', convert: function (val) { return val * 2 + 'rem' }}]
        })
    ]
})