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)
}
Hi I'm using the postcss-loader https://github.com/webpack-contrib/postcss-loader. My hope it compile out css custom props so my app will work on IE11. So far no luck. What is strange is despite having configured a plugin when I build webpack outputs that no plugins have been configured for postcss, but I feel I have
I have a configuration like :
{
test: /\.css$/i,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
[
'postcss-preset-env',
{
stage: 4,
custom-properties: false
},
],
],
},
},
},
],
},
Any help would be appreciate.