UNPKG

postcss-discard-comments

Version:

Discard comments in your CSS files with PostCSS.

36 lines (30 loc) 733 B
'use strict'; class CommentRemover { /** @param {import('../index.js').Options} options */ constructor(options) { this.options = options; } /** * @param {string} comment * @return {boolean | undefined} */ canRemove(comment) { const remove = this.options.remove; if (remove) { return remove(comment); } else { const isImportant = comment.indexOf('!') === 0; if (!isImportant) { return true; } if (this.options.removeAll || this._hasFirst) { return true; } else if (this.options.removeAllButFirst && !this._hasFirst) { this._hasFirst = true; return false; } } return false; } } module.exports = CommentRemover;