KC's Workspace
    Preparing search index...

    Class Result_<RootNode>

    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()
    

    Type Parameters

    Index

    Constructors

    Properties

    css: string

    A CSS string representing of Result#root.

    postcss.parse('a{}').toResult().css //=> "a{}"
    

    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())
    }
    messages: Message[]

    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
    
    processor: Processor_

    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: RootNode

    Root node after all transformations.

    root.toResult().root === root
    

    Accessors

    • get content(): string

      An alias for the Result#css property. Use it with syntaxes that generate non-CSS output.

      result.css === result.content
      

      Returns string

    Methods

    • Returns for Result#css content.

      result + '' === result.css
      

      Returns string

      String representing of Result#root.

    • Creates an instance of Warning and adds it to Result#messages.

      if (decl.important) {
      result.warn('Avoid !important', { node: decl, word: '!important' })
      }

      Parameters

      Returns Warning_

      Created warning.

    • Returns warnings from plugins. Filters Warning instances from Result#messages.

      result.warnings().forEach(warn => {
      console.warn(warn.toString())
      })

      Returns Warning_[]

      Warnings from plugins.