Skip to content
This repository was archived by the owner on Jan 6, 2024. It is now read-only.

Commit 11eafd9

Browse files
committed
feat: initial implementation
1 parent 41169f1 commit 11eafd9

File tree

6 files changed

+144
-0
lines changed

6 files changed

+144
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.idea
2+
node_modules

index.d.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Original definitions (@types/postcss-nested) by Maxim Vorontsov <https://github.com/VorontsovMaxim>
2+
3+
import { PluginCreator } from 'postcss';
4+
5+
declare namespace nested {
6+
interface Options {
7+
/**
8+
* By default, plugin will bubble only @media and @supports at-rules.
9+
* You can add your custom at-rules to this list by this option.
10+
*/
11+
bubble?: string[];
12+
13+
/**
14+
* By default, plugin will unwrap only @font-face, @keyframes and @document at-rules.
15+
* You can add your custom at-rules to this list by this option.
16+
*/
17+
unwrap?: string[];
18+
19+
/**
20+
* By default, plugin will strip out any empty selector generated by intermediate nesting
21+
* levels. You can set this option to true to preserve them.
22+
*/
23+
preserveEmpty?: boolean;
24+
}
25+
26+
type Nested = PluginCreator<Options>;
27+
}
28+
29+
declare const nested: nested.Nested;
30+
export = nested;

index.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const postcssNested = require("postcss-nested");
2+
3+
module.exports = (opts = {}) => {
4+
const instance = postcssNested(opts);
5+
6+
return {
7+
postcssPlugin: "postcss-nested-once",
8+
Once(root, postcssAPI) {
9+
root.walkRules((rule) => {
10+
instance.Rule(rule, postcssAPI);
11+
});
12+
},
13+
};
14+
};
15+
16+
module.exports.postcss = true;

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "postcss-nested-once",
3+
"version": "1.0.0",
4+
"description": "Postcss plugin to unwrap nested rules (like how Sass does it), compatible with rollup-plugin-styles",
5+
"keywords": [
6+
"postcss",
7+
"css",
8+
"postcss-plugin",
9+
"sass",
10+
"nested"
11+
],
12+
"main": "index.js",
13+
"type": "commonjs",
14+
"repository": "https://github.com/k-g-a/postcss-nested-once",
15+
"author": "Gleb Kochergin <[email protected]>",
16+
"license": "MIT",
17+
"private": false,
18+
"engines": {
19+
"node": ">=10.0"
20+
},
21+
"dependencies": {
22+
"postcss-nested": "^5.0.5"
23+
},
24+
"peerDependencies": {
25+
"postcss": "^8.3.5"
26+
},
27+
"devDependencies": {
28+
"postcss": "^8.3.5",
29+
"prettier": "^2.3.2"
30+
}
31+
}

yarn.lock

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
colorette@^1.2.2:
6+
version "1.2.2"
7+
resolved "https://registry.yarnpkg.com/colorette/-/colorette-1.2.2.tgz#cbcc79d5e99caea2dbf10eb3a26fd8b3e6acfa94"
8+
integrity sha512-MKGMzyfeuutC/ZJ1cba9NqcNpfeqMUcYmyF1ZFY6/Cn7CNSAKx6a+s48sqLqyAiZuaP2TcqMhoo+dlwFnVxT9w==
9+
10+
cssesc@^3.0.0:
11+
version "3.0.0"
12+
resolved "https://registry.yarnpkg.com/cssesc/-/cssesc-3.0.0.tgz#37741919903b868565e1c09ea747445cd18983ee"
13+
integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==
14+
15+
nanoid@^3.1.23:
16+
version "3.1.23"
17+
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.1.23.tgz#f744086ce7c2bc47ee0a8472574d5c78e4183a81"
18+
integrity sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==
19+
20+
postcss-nested@^5.0.5:
21+
version "5.0.5"
22+
resolved "https://registry.yarnpkg.com/postcss-nested/-/postcss-nested-5.0.5.tgz#f0a107d33a9fab11d7637205f5321e27223e3603"
23+
integrity sha512-GSRXYz5bccobpTzLQZXOnSOfKl6TwVr5CyAQJUPub4nuRJSOECK5AqurxVgmtxP48p0Kc/ndY/YyS1yqldX0Ew==
24+
dependencies:
25+
postcss-selector-parser "^6.0.4"
26+
27+
postcss-selector-parser@^6.0.4:
28+
version "6.0.6"
29+
resolved "https://registry.yarnpkg.com/postcss-selector-parser/-/postcss-selector-parser-6.0.6.tgz#2c5bba8174ac2f6981ab631a42ab0ee54af332ea"
30+
integrity sha512-9LXrvaaX3+mcv5xkg5kFwqSzSH1JIObIx51PrndZwlmznwXRfxMddDvo9gve3gVR8ZTKgoFDdWkbRFmEhT4PMg==
31+
dependencies:
32+
cssesc "^3.0.0"
33+
util-deprecate "^1.0.2"
34+
35+
postcss@^8.3.5:
36+
version "8.3.5"
37+
resolved "https://registry.yarnpkg.com/postcss/-/postcss-8.3.5.tgz#982216b113412bc20a86289e91eb994952a5b709"
38+
integrity sha512-NxTuJocUhYGsMiMFHDUkmjSKT3EdH4/WbGF6GCi1NDGk+vbcUTun4fpbOqaPtD8IIsztA2ilZm2DhYCuyN58gA==
39+
dependencies:
40+
colorette "^1.2.2"
41+
nanoid "^3.1.23"
42+
source-map-js "^0.6.2"
43+
44+
prettier@^2.3.2:
45+
version "2.3.2"
46+
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.3.2.tgz#ef280a05ec253712e486233db5c6f23441e7342d"
47+
integrity sha512-lnJzDfJ66zkMy58OL5/NY5zp70S7Nz6KqcKkXYzn2tMVrNxvbqaBpg7H3qHaLxCJ5lNMsGuM8+ohS7cZrthdLQ==
48+
49+
source-map-js@^0.6.2:
50+
version "0.6.2"
51+
resolved "https://registry.yarnpkg.com/source-map-js/-/source-map-js-0.6.2.tgz#0bb5de631b41cfbda6cfba8bd05a80efdfd2385e"
52+
integrity sha512-/3GptzWzu0+0MBQFrDKzw/DvvMTUORvgY6k6jd/VS6iCR4RDTKWH6v6WPwQoUO8667uQEf9Oe38DxAYWY5F/Ug==
53+
54+
util-deprecate@^1.0.2:
55+
version "1.0.2"
56+
resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
57+
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=

0 commit comments

Comments
 (0)