babel-plugin-jcss

1.0.3 • Public • Published

babel-plugin-jcss

custom babel plugin for template string css autoprefixing and minifying

Installation

npm install babel-plugin-jcss --save-dev

Usage

Include the following in your babel config, early in your plugins list.

  "plugins":[
    "@iosio/babel-plugin-jcss",
  ]

No import necessary

Babel will look for the tag 'jcss' with a tagged string, run the post css, minify the string and remove the tag before processing the rest of the code.

export const styles = jcss`   
        :host{
            display:flex;
            align-items:center;
            user-select:none;
        }
`;

Results will look something like this

export const styles = `:host{display:flex;align-items:center;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}`;

If you need a mock for non babel transpiled code, you can use something like this. It simply returns the combined template result as a single string.

function jcss(strings, ...values) {
    return strings.map((string, index) => `${string}${values[index] || ''}`).join('');
}

Package Sidebar

Install

npm i babel-plugin-jcss

Weekly Downloads

12

Version

1.0.3

License

MIT

Unpacked Size

8.77 kB

Total Files

4

Last publish

Collaborators

  • iosio