postcss-processor-splicer
Allow your postcss plugin pipeline to be modified like an array.
Example
var postcss = var Pipeline = { return { return { root } }} var A = postcssvar B = postcssvar C = postcssvar D = postcss var pipeline = A // creator // plugin // processor D name: 'd' // pipeline Promise { console console console console}
output:
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
apply all plugins: A, B, C, D :
x{}
a{}
b{}
c{}
d{}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
apply plugins B, C with default options :
x{}
b{}
c{}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
apply plugins A, D with options (only valid for creators) :
x{}
.a{}
.d{}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
splice, delete B, C :
x{}
a{}
d{}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
unshift plugin B :
x{}
b{}
a{}
d{}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
push creator C :
x{}
b{}
a{}
d{}
c{}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
modify default options for creator C :
x{}
b{}
a{}
d{}
.c{}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
pop creator C :
x{}
b{}
a{}
d{}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
shift plugin B :
x{}
a{}
d{}
pipeline = new Pipeline(creators)
Create a pipeline of creators.
creators
Type: Array
Elements could be postcss plugins, postcss plugin creators, instances of Pipeline. To set default options, just pass an array as the element.
pipeline.[ArrayLikeMethods]
Modify the builtin creators.
ArrayLikeMethods
could be one of the following:
splice
push
pop
shift
unshift
creator = pipeline.get(...postcssPlugin)
Get the internal representation of the creators according to the given plugin names or indexes.
creator
Representation of a creator.
Type: Array
The first element could be a postcss plugin function,
or postcss creator function (created with postcss.plugin
).
Other elements are passed to the creator as options when build the plugin function.
postcssPlugin
Type: String
, Number
Plugin name, or indexes in the pipeline.
pipeline.build(...creators)
Create a postcss processor from given creators, or creators in the pipeline.
You can use the plugin name or index to specify the plugin.