tree: 141f5505bc437930d4e3423afa47ee062ac5c255 [path history] [tgz]
  1. camel-case.js
  2. extract.js
  3. get-template.js
  4. index.js
  5. LICENSE
  6. literal.js
  7. object-parse.js
  8. object-parser.js
  9. object-stringifier.js
  10. object-stringify.js
  11. object-syntax.js
  12. object.js
  13. package.json
  14. README.md
  15. template-parse.js
  16. template-parser-helper.js
  17. template-parser.js
  18. template-safe-parse.js
  19. template-safe-parser.js
  20. template-stringifier.js
  21. template-stringify.js
  22. template-tokenize.js
  23. un-camel-case.js
node_modules/postcss-jsx/README.md

PostCSS JSX Syntax

NPM version Travis Travis Codecov David

PostCSS syntax for parsing CSS in JS literals:

Getting Started

First thing's first, install the module:

npm install postcss-syntax postcss-jsx --save-dev

Use Cases

const postcss = require('postcss');
const stylelint = require('stylelint');
const syntax = require('postcss-syntax');
postcss([stylelint({ fix: true })]).process(source, { syntax: syntax }).then(function (result) {
	// An alias for the result.css property. Use it with syntaxes that generate non-CSS output.
	result.content
});

input:

import glm from 'glamorous';
const Component1 = glm.a({
	flexDirectionn: 'row',
	display: 'inline-block',
	color: '#fff',
});

output:

import glm from 'glamorous';
const Component1 = glm.a({
	color: '#fff',
	display: 'inline-block',
	flexDirectionn: 'row',
});

Advanced Use Cases

Add support for more css-in-js package:

const syntax = require('postcss-syntax')({
	"i-css": (index, namespace) => namespace[index + 1] === "addStyles",
	"styled-components": true,
});

See: postcss-syntax

Style Transformations

The main use case of this plugin is to apply PostCSS transformations to CSS code in template literals & styles as object literals.