1.0.3 • Published 4 years ago

write-j2c v1.0.3

Weekly downloads
36
License
MIT
Repository
-
Last release
4 years ago

Write j2c to CSS

Usage

writej2c(options)

Example

// styles.js
export default = [
  {
    '.red.strong': {
      color: '#f00',
      fontWeight: 'bold'
    }
  },
  {
    '.header': [
      {
        '&.h1': {
          'font-weight': 'bold'
        }
      },
      {
        '&.h1': {
          'color': '#000'
        }
      }
    ]
  },
];
// postbuild.js
import { writej2c } from "write-j2c"
import styles from "./styles"

writej2c({
  styles,
  path: "./dist/app.css",
  beautify: true
})

Creates:

.red.strong {
  color: red;
  font-weight: 700;
}

.header.h1 {
  font-weight: 700;
  color: #000;
}

Options

ParameterRequiredTypeDefaultDescription
stylesrequiredArray of J2C stylesSee j2c documentation
pathrequiredStringWhere to save the output CSS file
autoPrefixoptionalBooleanfalseSet to true to add vendor prefixes; not needed if your bundler writes prefixes
beautifyoptionalBooleanfalseSet to true to beautify the output (by default the output is minified)
gzipoptionalBooleanfalseSet to true to export a .gz file (next to the regular output file)
wrapInGlobaloptionalBooleanfalseTo use with CSS Modules: set to true to wrap the generated css inside a :global { ... } tag