Skip to content

Commit

Permalink
fix: drop deprecated postcss.plugin function
Browse files Browse the repository at this point in the history
  • Loading branch information
fengyuanchen committed Feb 13, 2022
1 parent 8d4eca5 commit a966399
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
const postcss = require('postcss');

module.exports = postcss.plugin('postcss-header', (options = {}) => {
module.exports = (options = {}) => {
options = Object.assign({
header: '',
}, options);

return (css) => {
const header = options.header || options.banner;
return {
postcssPlugin: 'postcss-header',
Once(root) {
const header = options.header || options.banner;

if (header) {
css.prepend(header);
}
if (header) {
root.prepend(header);
}
},
};
});
};
module.exports.postcss = true;

0 comments on commit a966399

Please sign in to comment.