exports
in package.json
? I tried the following, but I’m getting an error about an "incorrect type":"exports": {
"node": {
"require": "./dist/index.cjs"
}
}
class Plugin {
get postcssPlugin() {
return 'to-red'
}
Declaration(decl) {
console.log(decl.toString())
decl.value = 'red'
}
static get postcss() {
return true
}
}
postcss([ Plugin ]).process('a { color: black }', { from: '!' }).then(({ css }) => console.log(css))
postcss/lib/processor.js:40
i = i()
^
TypeError: Class constructor Plugin cannot be invoked without 'new'
Hi, folks, trying to add some declaration to each rule, isn't this considered as right usage?
module.exports = opts => ({
postcssPlugin: 'postcss-plugin',
Rule (rule) {
rule.prepend({ prop: 'background-image', value: `url('path/url')` });
}
});
It goes through each rule but does not modify the results (rule.nodes after prepend() remain the same) :(
Is the only option to use Root () {} method and walk through each rule explicitly?
Rule (rule, { Declaration }) {
let color = new Declaration({ prop: 'color', value: 'black' })
rule.append(color)
}