Help with ESM plugin
#1903
|
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 pluginindex.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,
],
},
})
}) |
Answered by
ai
Dec 6, 2023
Replies: 2 comments
|
Plugin looks good. I think the problem is somewhere in |
0 replies
Answer selected by
cossssmin
|
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)
})
})
} |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Plugin looks good. I think the problem is somewhere in
index.js