Input

Input

Represents the source CSS.

Constructor

new Input(css, optsopt)

Source:
Example
const root  = postcss.parse(css, { from: file });
const input = root.source.input;
Parameters:
Name Type Attributes Description
css string

input CSS source

opts object <optional>

Processor#process options

Members

css :string

Source:

input CSS source

Type:
  • string
Example
const input = postcss.parse('a{}', { from: file }).input;
input.css //=> "a{}";

file :string

Source:

The absolute path to the CSS source file defined with the from option.

Type:
  • string
Example
const root = postcss.parse(css, { from: 'a.css' });
root.source.input.file //=> '/home/ai/a.css'

from :string

Source:

The CSS source identifier. Contains Input#file if the user set the from option, or Input#id if they did not.

Type:
  • string
Example
const root = postcss.parse(css, { from: 'a.css' });
root.source.input.from //=> "/home/ai/a.css"

const root = postcss.parse(css);
root.source.input.from //=> "<input css 1>"

id :string

Source:

The unique ID of the CSS source. It will be created if from option is not provided (because PostCSS does not know the file path).

Type:
  • string
Example
const root = postcss.parse(css);
root.source.input.file //=> undefined
root.source.input.id   //=> "<input css 1>"

map :PreviousMap

Source:

The input source map passed from a compilation step before PostCSS (for example, from Sass compiler).

Type:
Example
root.source.input.map.consumer().sources //=> ['a.sass']

Methods

origin(line, column) → {filePosition}

Source:

Reads the input source map and returns a symbol position in the input source (e.g., in a Sass file that was compiled to CSS before being passed to PostCSS).

Example
root.source.input.origin(1, 1) //=> { file: 'a.css', line: 3, column: 1 }
Parameters:
Name Type Description
line number

line in input CSS

column number

column in input CSS

Returns:

position in input source

Type
filePosition