|
|
2 سال پیش | |
|---|---|---|
| .. | ||
| CHANGELOG.md | 2 سال پیش | |
| LICENSE | 2 سال پیش | |
| README.md | 2 سال پیش | |
| camel-case.js | 2 سال پیش | |
| extract.js | 2 سال پیش | |
| get-template.js | 2 سال پیش | |
| index.js | 2 سال پیش | |
| literal.js | 2 سال پیش | |
| object-parse.js | 2 سال پیش | |
| object-parser.js | 2 سال پیش | |
| object-stringifier.js | 2 سال پیش | |
| object-stringify.js | 2 سال پیش | |
| object-syntax.js | 2 سال پیش | |
| object.js | 2 سال پیش | |
| package.json | 2 سال پیش | |
| template-parse.js | 2 سال پیش | |
| template-parser-helper.js | 2 سال پیش | |
| template-parser.js | 2 سال پیش | |
| template-safe-parse.js | 2 سال پیش | |
| template-safe-parser.js | 2 سال پیش | |
| template-stringifier.js | 2 سال پیش | |
| template-stringify.js | 2 سال پیش | |
| template-tokenize.js | 2 سال پیش | |
| un-camel-case.js | 2 سال پیش | |
<img align="right" width="95" height="95"
title="Philosopher’s stone, logo of PostCSS"
src="https://api.postcss.org/logo.svg">
PostCSS syntax for parsing CSS in JS literals:
First thing's first, install the module:
npm install postcss-syntax @stylelint/postcss-css-in-js --save-dev
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"
});
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
The main use case of this plugin is to apply PostCSS transformations to CSS code in template literals & styles as object literals.