Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PostCSS Extract Variable Scheme PostCSS Logo

PostCSS Extract Variable Scheme lets you export custom properties, selectors and media queries to one or multiple files based on a prefix you define in your variable name.

Installation

npm install postcss-extract-variable-scheme

Usage

With following setup (incomplete) ..

var postcss = require("postcss")
var extractVariableScheme = require("postcss-extract-variable-scheme")

var output = postcss()
  .use(extractVariableScheme({
    dest: 'build/variables/',
    fileExports: [
      {
        prefixes: ['my-prefix'],
        filename: 'example'
      }
    ]
  }))
  .process(cssFile)
  .css

Processing following CSS:

:root {
  --my-prefix-h1-size: 2rem;
  --my-prefix-box: {
    background-color: #000;
    font-weight: bold;
  }
}

Variables with --{prefix}- (Please note the finishing "-") get extracted to example.json:

{
  "my-prefix-h1-size": "2rem",
  "my-prefix-box": {
    "background-color": "#000",
    "font-weight": "bold"
  }
}

Options

dist

Defines the Directory the file exports get written.

fileExports

Array of objects that specify individual exporters. Prefixes can be used multiple times with different exports.

[
  {
    prefixes: ['my-prefix'],
    filename: 'example'
  }
]

About

Export custom variables to multiple json files based on naming prefixes.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages