A CSS processor with a simple plugin design that can process CSS server-side and client-side into CSS, JS, and other file output
This package is delivered in CJS format and an ES module.
// Node
const processCSS = require('../index.cjs.js')
<!-- browser script -->
<script src=../index.cjs.js></script>
// Deno
import processCSS from '../index.js'
<!-- browser module -->
<script type=module>
import processCSS from '../index.js'
<script>
process(stringOfCSS, listOfPlugins, environment)
stringOfCSS
is a string containing a CSS stylesheet - one or more ruleslistOfPlugins
is an array ofprocess-css
plugin functionsenvironment
is an optional object that may include any data you want to make available to the plugins in thelistOfPlugins
as they process thestringOfCSS
function(string, environment) {
return {
css: '',
js: '',
otherFiles: {}
}
}
-
every
process-css
plugin is a function that accepts a string, this is either the input CSS if this is the first plugin in thelistofPlugins
to be processed, or will be given the previous plugin'sresult.css
from the return object of the previously run plugin as its input -
every
process-css
plugin may optionally accept an object containing any data or values you want available to the plugin while it does its transformation -
every
process-css
plugin returns an object optionally containing: -
- a
css
property with a string of CSS to pass to the next plugin in thelistOfPlugins
or as the final output if it's the last plugin to be processed.
- a
-
- a
js
property with a string of JavaScript to accumulate any JavaScript output that is generated by your plugins
- a
-
- a
otherFiles
object which contains key/value pairs where the keys represent filenames of additional files you want to output, and the value contains the text content of those files
- a