-
Can someone share some insight into what I'm doing wrong here please? I'm not seeing the Here's what I have: _removeImportantPlugin.jsconst plugin = () => {
console.log('✅ Seeing this logged!')
return {
postcssPlugin: 'postcss-remove-important',
Declaration (decl) {
console.log('❌ Not seeing this logged...')
if (decl.important) {
decl.important = false
}
}
}
}
plugin.postcss = true
export default plugin index.jsThis is a PostHTML plugin that walks nodes and parses their content with PostCSS. const processStyleTags = (node, tree, options = {}) => {
return new Promise((resolve, reject) => {
try {
const postcssPlugins = options.postcss?.plugins || []
const { result } = postcss(postcssPlugins).process(node.content.join(' '), {from: undefined})
resolve({node})
} catch (error) {
reject(error)
}
})
} test.jsUsing AVA to test, import removeImportant from './stubs/_removeImportantPlugin.js'
test('PostCSS plugins', t => {
return process(t, 'postcss-plugins', {
postcss: {
plugins: [
removeImportant,
],
},
})
}) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Plugin looks good. I think the problem is somewhere in |
Beta Was this translation helpful? Give feedback.
-
Indeed it was, fixed the promise and now it's working fine :) const processStyleTags = (node, tree, options = {}) => {
return new Promise((resolve, reject) => {
postcss(options.postcss?.plugins || [])
.process(node.content.join(' '), {from: undefined})
.then(result => {
node.content = [result.root.toString()]
resolve({node})
})
.catch(error => {
reject(error)
})
})
} |
Beta Was this translation helpful? Give feedback.
Plugin looks good. I think the problem is somewhere in
index.js