postcss-modules-sync

1.0.0 • Public • Published

postcss-modules-sync

A PostCSS plugin to use CSS Modules synchronously in js.

version MIT License

Install

npm install postcss-modules-sync

Example

import CSSModulesSync from 'postcss-modules-sync'
import postcss from 'postcss'
 
const css = `
  :global .text {
    color: white;
    background-color: gray;
  }
 
  .green {
    background-color: green;
  }
 
  .blue {
    background-color: blue;
  }
 
  .default {
    composes: green;
    display: flex;
  }
`
 
let exportedTokens = {}
const styles = postcss([
  CSSModulesSync({
    generateScopedName: '[path][local]-[hash:base64:10]',
    getJSON: tokens => exportedTokens = tokens
  })
]).process(css).css
 
console.log('styles', styles)
console.log('tokens', exportedTokens)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    38,113
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    38,113
  • 0.1.0
    2

Package Sidebar

Install

npm i postcss-modules-sync

Weekly Downloads

31,906

Version

1.0.0

License

MIT

Last publish

Collaborators

  • schiehll