Last change
on this file since ceaed42 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
947 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | "use strict";
|
---|
| 2 |
|
---|
| 3 | Object.defineProperty(exports, "__esModule", {
|
---|
| 4 | value: true
|
---|
| 5 | });
|
---|
| 6 | exports.default = void 0;
|
---|
| 7 | const plugin = 'postcss-discard-empty';
|
---|
| 8 |
|
---|
| 9 | function discardAndReport(css, result) {
|
---|
| 10 | function discardEmpty(node) {
|
---|
| 11 | const {
|
---|
| 12 | type,
|
---|
| 13 | nodes: sub,
|
---|
| 14 | params
|
---|
| 15 | } = node;
|
---|
| 16 |
|
---|
| 17 | if (sub) {
|
---|
| 18 | node.each(discardEmpty);
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | if (type === 'decl' && !node.value || type === 'rule' && !node.selector || sub && !sub.length || type === 'atrule' && (!sub && !params || !params && !sub.length)) {
|
---|
| 22 | node.remove();
|
---|
| 23 | result.messages.push({
|
---|
| 24 | type: 'removal',
|
---|
| 25 | plugin,
|
---|
| 26 | node
|
---|
| 27 | });
|
---|
| 28 | }
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | css.each(discardEmpty);
|
---|
| 32 | }
|
---|
| 33 |
|
---|
| 34 | function pluginCreator() {
|
---|
| 35 | return {
|
---|
| 36 | postcssPlugin: plugin,
|
---|
| 37 |
|
---|
| 38 | OnceExit(css, {
|
---|
| 39 | result
|
---|
| 40 | }) {
|
---|
| 41 | discardAndReport(css, result);
|
---|
| 42 | }
|
---|
| 43 |
|
---|
| 44 | };
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | pluginCreator.postcss = true;
|
---|
| 48 | var _default = pluginCreator;
|
---|
| 49 | exports.default = _default;
|
---|
| 50 | module.exports = exports.default; |
---|
Note:
See
TracBrowser
for help on using the repository browser.