import { postcss } from "https://deno.land/x/bundler@0.6.5/deps.ts";
const { Result } = postcss;
Provides the result of the PostCSS transformations.
A Result instance is returned by LazyResult#then
or Root#toResult
methods.
postcss([autoprefixer]).process(css).then(result => {
console.log(result.css)
})
const result2 = postcss.parse(css).toResult()
Constructors
Properties
An alias for the Result#css
property.
Use it with syntaxes that generate non-CSS output.
result.css === result.content
Last runned PostCSS plugin.
An instance of SourceMapGenerator
class from the source-map
library,
representing changes to the Result#root
instance.
result.map.toJSON() //=> { version: 3, file: 'a.css', … }
if (result.map) {
fs.writeFileSync(result.opts.to + '.map', result.map.toString())
}
Contains messages from plugins (e.g., warnings or custom messages). Each message should have type and plugin properties.
AtRule: {
import: (atRule, { result }) {
const importedFile = parseImport(atRule)
result.messages.push({
type: 'dependency',
plugin: 'postcss-import',
file: importedFile,
parent: result.opts.from
})
}
}
Options from the Processor#process
or Root#toResult
call
that produced this Result instance.]
root.toResult(opts).opts === opts
The Processor instance used for this transformation.
for (const plugin of result.processor.plugins) {
if (plugin.postcssPlugin === 'postcss-bad') {
throw 'postcss-good is incompatible with postcss-bad'
}
})
Root node after all transformations.
root.toResult().root === root
Methods
Returns for Result#css
content.
result + '' === result.css
Creates an instance of Warning
and adds it to Result#messages
.
if (decl.important) {
result.warn('Avoid !important', { node: decl, word: '!important' })
}