postcss-generate-ts-hash
v0.1.0
Published
PostCSS plugin that generate a TypeScript hash of all classes with comments
Downloads
4
Maintainers
Readme
PostCSS Generate TypeScript Hash
[PostCSS] plugin that generate a TypeScript hash of all classes with comments.
Given CSS code like this
.foo {
font-size: big;
}
.bar-baz {
color: hotpink;
}
this plugin generate a TypeScript code like this:
export const classes = {
/** .foo */
foo: 'foo',
/** .bar-baz */
barBaz: 'bar-baz',
}
That can be used in you DOM related code:
import {classes} from './classes';
const div = document.createElement('div');
div.className = classes.foo;
Usage
postcss([ require('postcss-generate-ts-hash')(done: function(tsFileString) { /* save it to a file... */ }) ])
Options
Pass exportEach
to options to have output like this:
/** .foo */
export const foo = 'foo';
/** .bar-baz */
export const barBaz = 'bar-baz';
See [PostCSS] docs for examples for your environment.