Skip to content

ArthurClemens/write-j2c

Repository files navigation

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

About

Write j2c to CSS files

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published