ai on ose
Fix package.json order (compare)
ai on ose
Add fast scanning rule (compare)
ai on ose
Clean up code Add fast filters for decl props… (compare)
ai on ose
Update PrettierX (compare)
ai on ose
Use logo from official website Update plugin guidelines (compare)
"postcss-import": {}, at the beginning of my plugin list
@use. Are there any plans to make this a default part of PostCSS?
:root {} node for the css vars the plugin is outputting, I'd like to be able to push all of the nodes into the same :root {} instance...
:root {} blocks you could get each plugin to add a comment and the look for root blocks with those comments.
ctx object?
What do you think about this new plugin API for PostCSS 8?
https://twitter.com/PostCSS/status/1291507810216230912
/cc @jonathantneal @limitlessloop
// before
const postcss = require('postcss')
module.exports = postcss.plugin('name', (opts) => {
return root => {
root.on('decl', (node, index) => {
if (node.prop === 'will-change') {
node.cloneBefore({ prop: 'backface-visibility', value: 'hidden' })
}
})
}
})// after
module.exports = (opts) => ({
postcssPlugin: 'name',
decl(decl) {
if (node.prop === 'will-change') {
node.cloneBefore({ prop: 'backface-visibility', value: 'hidden' })
}
}
})
module.exports.postcss = true
t.
decl(decl, result, postcss) order?
or we can add all postcss helpers to the result
/cc @jonathantneal
export default (opts, { parse: { commaSeparatedList, spaceSeparatedList } }) => ({
name: "my-plugin",
visitor: {
Declaration(node) {
if (node.name.toLowerCase() === 'will-change') {
node.cloneBefore({ name: 'backface-visibility', value: 'hidden' })
}
}
}
})
export default (opts) => ({
name: "my-plugin",
visitor: {
Declaration(node, { parse: { commaSeparatedList, spaceSeparatedList }, result }) {
if (node.name.toLowerCase() === 'will-change') {
node.cloneBefore({ name: 'backface-visibility', value: 'hidden' })
}
}
}
})
decl (node, { result, list }) {
}
So, in the new plugin API, the main function would still get passed an options object, but its return value could be an object. And that object could support visitors. I love that.
I would recommend bundling visitors within a visitor field, as I did in the example, and then naming them by their class. I think it would be logical and familiar. Not only does it cross-inform authors of the relationship between the visitor and the type, but it comfortably matches the expectations in Babel.
declExit and not Delcarataion: { exit }
postcss to a plugin’s and runner’s peerDependencies?
postcss to peerDependencies/devDependencies.
postcss” ships as the second argument to a visitor. Although, it seems more like the processor object, with result tagged on for good measure. :D
list (as normally imported from PostCSS in v7).
Declaration. In my defense, that is what we call it in CSS, and that is what we call it in the PostCSS documentation, and what it is named as a class in the source. Just sayin’. Just sayin’. (Do forgive my silly mood.)