write-j2c

Write j2c to CSS files

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
write-j2c
1.0.34 years ago4 years agoMinified + gzip package size for write-j2c in KB

Readme

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

| Parameter | Required | Type | Default | Description | | ---------------- | -------------- | -------------------- | ----------- | --------------- | | styles | required | Array of J2C styles | | See j2c documentation | | path | required | String | | Where to save the output CSS file | | autoPrefix | optional | Boolean | false | Set to true to add vendor prefixes; not needed if your bundler writes prefixes | | beautify | optional | Boolean | false | Set to true to beautify the output (by default the output is minified) | | gzip | optional | Boolean | false | Set to true to export a .gz file (next to the regular output file) | | wrapInGlobal | optional | Boolean | false | To use with CSS Modules: set to true to wrap the generated css inside a :global { ... } tag |