Skip to main content
The Deno 2 Release Candidate is here
Learn more
Latest
interface Postcss
import { type Postcss } from "https://deno.land/x/postcss@8.4.16/lib/postcss.js";

Call Signatures

(plugins?: AcceptedPlugin[]): Processor

Create a new Processor instance that will apply plugins as CSS processors.

import { postcss } from "./deps.js"


postcss(plugins).process(css, { from, to }).then(result => {
  console.log(result.css)
})
(...plugins: AcceptedPlugin[]): Processor

Properties

stringify: Stringifier

Default function to convert a node tree into a CSS string.

parse: Parser<Root>

Parses source css and returns a new Root or Document node, which contains the source CSS nodes.

// Simple CSS concatenation with source map support
const root1 = postcss.parse(css1, { from: file1 })
const root2 = postcss.parse(css2, { from: file2 })
root1.append(root2).toResult().css
fromJSON: JSONHydrator

Rehydrate a JSON AST (from Node#toJSON) back into the AST classes.

const json = root.toJSON()
// save to file, send by network, etc
const root2  = postcss.fromJSON(json)
list: List

Contains the list module.

CssSyntaxError: CssSyntaxError
Declaration: Declaration
Container: Container
Comment: Comment
Warning: Warning
AtRule: AtRule
Result: Result
Input: Input
Rule: Rule
Root: Root
Node: Node

Methods

comment(defaults?: CommentProps): Comment

Creates a new Comment node.

atRule(defaults?: AtRuleProps): AtRule

Creates a new AtRule node.

decl(defaults?: DeclarationProps): Declaration

Creates a new Declaration node.

rule(defaults?: RuleProps): Rule

Creates a new Rule node.

root(defaults?: RootProps): Root

Creates a new Root node.

document(defaults?: DocumentProps): Document

Creates a new Document node.