summaryrefslogtreecommitdiff
path: root/node_modules/postcss-discard-empty
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/postcss-discard-empty')
-rw-r--r--node_modules/postcss-discard-empty/LICENSE-MIT22
-rw-r--r--node_modules/postcss-discard-empty/README.md49
-rw-r--r--node_modules/postcss-discard-empty/package.json41
-rw-r--r--node_modules/postcss-discard-empty/src/index.js57
-rw-r--r--node_modules/postcss-discard-empty/types/index.d.ts9
5 files changed, 178 insertions, 0 deletions
diff --git a/node_modules/postcss-discard-empty/LICENSE-MIT b/node_modules/postcss-discard-empty/LICENSE-MIT
new file mode 100644
index 00000000..fd0e863a
--- /dev/null
+++ b/node_modules/postcss-discard-empty/LICENSE-MIT
@@ -0,0 +1,22 @@
+Copyright (c) Ben Briggs <beneb.info@gmail.com> (http://beneb.info)
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/postcss-discard-empty/README.md b/node_modules/postcss-discard-empty/README.md
new file mode 100644
index 00000000..c481a780
--- /dev/null
+++ b/node_modules/postcss-discard-empty/README.md
@@ -0,0 +1,49 @@
+# [postcss][postcss]-discard-empty
+
+> Discard empty rules and values with PostCSS.
+
+## Install
+
+With [npm](https://npmjs.org/package/postcss-discard-empty) do:
+
+```
+npm install postcss-discard-empty --save
+```
+
+## Example
+
+For more examples see the [tests](src/__tests__/index.js).
+
+### Input
+
+```css
+@font-face;
+h1 {}
+{color:blue}
+h2 {color:}
+h3 {color:red}
+```
+
+### Output
+
+```css
+h3 {color:red}
+```
+
+## Usage
+
+See the [PostCSS documentation](https://github.com/postcss/postcss#usage) for
+examples for your environment.
+
+
+## Contributors
+
+See [CONTRIBUTORS.md](https://github.com/cssnano/cssnano/blob/master/CONTRIBUTORS.md).
+
+
+## License
+
+MIT © [Ben Briggs](http://beneb.info)
+
+
+[postcss]: https://github.com/postcss/postcss
diff --git a/node_modules/postcss-discard-empty/package.json b/node_modules/postcss-discard-empty/package.json
new file mode 100644
index 00000000..0c23b6bb
--- /dev/null
+++ b/node_modules/postcss-discard-empty/package.json
@@ -0,0 +1,41 @@
+{
+ "name": "postcss-discard-empty",
+ "version": "6.0.0",
+ "description": "Discard empty rules and values with PostCSS.",
+ "main": "src/index.js",
+ "types": "types/index.d.ts",
+ "files": [
+ "src",
+ "LICENSE-MIT",
+ "types"
+ ],
+ "keywords": [
+ "compress",
+ "css",
+ "empty",
+ "minify",
+ "optimisation",
+ "postcss",
+ "postcss-plugin"
+ ],
+ "license": "MIT",
+ "homepage": "https://github.com/cssnano/cssnano",
+ "author": {
+ "name": "Ben Briggs",
+ "email": "beneb.info@gmail.com",
+ "url": "http://beneb.info"
+ },
+ "repository": "cssnano/cssnano",
+ "bugs": {
+ "url": "https://github.com/cssnano/cssnano/issues"
+ },
+ "engines": {
+ "node": "^14 || ^16 || >=18.0"
+ },
+ "devDependencies": {
+ "postcss": "^8.2.15"
+ },
+ "peerDependencies": {
+ "postcss": "^8.2.15"
+ }
+} \ No newline at end of file
diff --git a/node_modules/postcss-discard-empty/src/index.js b/node_modules/postcss-discard-empty/src/index.js
new file mode 100644
index 00000000..77f32494
--- /dev/null
+++ b/node_modules/postcss-discard-empty/src/index.js
@@ -0,0 +1,57 @@
+'use strict';
+const plugin = 'postcss-discard-empty';
+/**
+ * @param {import('postcss').Root} css
+ * @param {import('postcss').Result} result
+ * @return {void}
+ */
+function discardAndReport(css, result) {
+ /**
+ * @param {import('postcss').AnyNode} node
+ * @return {void}
+ */
+ function discardEmpty(node) {
+ const { type } = node;
+ /** @type {(import('postcss').ChildNode | import('postcss').ChildProps)[] | undefined} */
+ const sub = /** @type {any} */ (node).nodes;
+ if (sub) {
+ /** @type {import('postcss').Container} */ (node).each(discardEmpty);
+ }
+
+ if (
+ (type === 'decl' && !node.value && !node.prop.startsWith('--')) ||
+ (type === 'rule' && !node.selector) ||
+ (sub && !sub.length) ||
+ (type === 'atrule' &&
+ ((!sub && !node.params) ||
+ (!node.params &&
+ !(/** @type {import('postcss').ChildNode[]}*/ (sub).length))))
+ ) {
+ node.remove();
+
+ result.messages.push({
+ type: 'removal',
+ plugin,
+ node,
+ });
+ }
+ }
+
+ css.each(discardEmpty);
+}
+
+/**
+ * @type {import('postcss').PluginCreator<void>}
+ * @return {import('postcss').Plugin}
+ */
+function pluginCreator() {
+ return {
+ postcssPlugin: plugin,
+ OnceExit(css, { result }) {
+ discardAndReport(css, result);
+ },
+ };
+}
+
+pluginCreator.postcss = true;
+module.exports = pluginCreator;
diff --git a/node_modules/postcss-discard-empty/types/index.d.ts b/node_modules/postcss-discard-empty/types/index.d.ts
new file mode 100644
index 00000000..d2beadb6
--- /dev/null
+++ b/node_modules/postcss-discard-empty/types/index.d.ts
@@ -0,0 +1,9 @@
+export = pluginCreator;
+/**
+ * @type {import('postcss').PluginCreator<void>}
+ * @return {import('postcss').Plugin}
+ */
+declare function pluginCreator(): import('postcss').Plugin;
+declare namespace pluginCreator {
+ const postcss: true;
+}