I'll need some help for the v1 docs. The general API is
const j2c = new J2c(options)
const cssText = j2c.sheet({'.foo': {color: 'red'}})
j2c.names.foo // "random_prefix_1_foo"
const otherCssText = j2c.sheet({'.bar': {color: 'red'}})
j2c.names.bar // "random_prefix_1_bar"
// shares all the options of the first instance except the prefix and `names` dict
const otherInstance = j2c.ns()
Object.keys(otherInstance.names).length // 0
const cssText = otherInstance.sheet({'.foo': {color: 'red'}})
otherInstance.names.foo // "random_prefix_2_foo"
The idea is that the initial setup (new J2c(options)
) is potentially costly (creation of many closures to generate the various parts of the processors with the plugin calls inlined). in order to get better perf out of the result.
The advice I'm seeking would be how to name local instance with their own prefix... J2c
/j2c
seems Ok for the constructor and main instance...
.ns()
for a given length, or by passing a string to be used as prefix (BEM-style).
@ArthurClemens the next docs already have more about at-rules actually:
All standard CSS at-rules are available out of the box, most importantly:
@media
and@supports
, which can be nested anywhere in the sheet, SASS-style.@keyframes
@font-face
position: fixed
...
.mjs
, this combination works for both.
module
should have pointed to main.js
that only exports the public function, the other exports in plugin.js
are meant for testing IIRC
mjs
mandatory for modules with Webpack 4?
import { prefixPlugin } from "j2c-plugin-prefix-browser/dist/j2c-plugin-prefix-browser.commonjs”;