postcss-import-glob 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +90 -0
- package/index.js +38 -0
- package/package.json +74 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
=====================
|
|
3
|
+
Copyright © 2026 [Daniel Bayley](https://github.com/danielbayley) <daniel.bayley@me.com>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
[PostCSS] `@import` [glob]
|
|
2
|
+
==========================
|
|
3
|
+
PostCSS [plugin] to inline CSS [`@import`]s, with support for [glob] patterns.
|
|
4
|
+
|
|
5
|
+
Usage
|
|
6
|
+
-----
|
|
7
|
+
`a.css`:
|
|
8
|
+
~~~ css
|
|
9
|
+
* { content: "a" }
|
|
10
|
+
~~~
|
|
11
|
+
`b.css`:
|
|
12
|
+
~~~ css
|
|
13
|
+
* { content: "b" }
|
|
14
|
+
~~~
|
|
15
|
+
~~~ js
|
|
16
|
+
import postcss from "postcss"
|
|
17
|
+
import imports from "postcss-import-glob"
|
|
18
|
+
|
|
19
|
+
const css = '@import "*.css";'
|
|
20
|
+
const post = await postcss([imports]).process(css, { from: undefined, to: "post.css" })
|
|
21
|
+
console.log(post.css)
|
|
22
|
+
~~~
|
|
23
|
+
`post.css`:
|
|
24
|
+
~~~ css
|
|
25
|
+
* { content: "a" }
|
|
26
|
+
* { content: "b" }
|
|
27
|
+
~~~
|
|
28
|
+
|
|
29
|
+
## Examples
|
|
30
|
+
~~~ css
|
|
31
|
+
@import "style.css";
|
|
32
|
+
@import 'style.css';
|
|
33
|
+
@import url(style.css);
|
|
34
|
+
@import url("style.css");
|
|
35
|
+
@import url('style.css');
|
|
36
|
+
|
|
37
|
+
@import "*.css";
|
|
38
|
+
@import '*.css';
|
|
39
|
+
@import "**/*.css";
|
|
40
|
+
@import url(**/*.css);
|
|
41
|
+
@import url(*.css);
|
|
42
|
+
@import url("*.css");
|
|
43
|
+
@import url('*.css')
|
|
44
|
+
~~~
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
~~~ sh
|
|
48
|
+
pnpm add postcss postcss-import-glob
|
|
49
|
+
~~~
|
|
50
|
+
> [!IMPORTANT]
|
|
51
|
+
> This package is _[ESM]_ [only], so must be [`import`]ed instead of [`require`]d,
|
|
52
|
+
> and [depends] on [_Node_.js] [`>=`][][`20`].
|
|
53
|
+
|
|
54
|
+
Specify this requirement with [`engines`] and/or [`devEngines`]:
|
|
55
|
+
~~~ jsonc
|
|
56
|
+
// package.json
|
|
57
|
+
"type": "module",
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=20"
|
|
60
|
+
},
|
|
61
|
+
"devEngines": {
|
|
62
|
+
"runtime": {
|
|
63
|
+
"name": "node",
|
|
64
|
+
"version": ">=20"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
~~~
|
|
68
|
+
|
|
69
|
+
License
|
|
70
|
+
-------
|
|
71
|
+
[MIT] © [Daniel Bayley]
|
|
72
|
+
|
|
73
|
+
[MIT]: LICENSE.md
|
|
74
|
+
[Daniel Bayley]: https://github.com/danielbayley
|
|
75
|
+
|
|
76
|
+
[_Node_.js]: https://nodejs.org
|
|
77
|
+
[ESM]: https://developer.mozilla.org/docs/Web/JavaScript/Guide/Modules
|
|
78
|
+
[only]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
|
|
79
|
+
[`import`]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/import
|
|
80
|
+
[`require`]: https://nodejs.org/api/modules.html#requireid
|
|
81
|
+
[depends]: https://docs.npmjs.com/cli/v11/configuring-npm/package-json#engines
|
|
82
|
+
[`>=`]: https://docs.npmjs.com/cli/v6/using-npm/semver#ranges
|
|
83
|
+
[`20`]: https://github.com/nodejs/node/blob/main/doc/changelogs/CHANGELOG_V20.md
|
|
84
|
+
[`engines`]: https://docs.npmjs.com/cli/v11/configuring-npm/package-json#engines
|
|
85
|
+
[`devEngines`]: https://docs.npmjs.com/cli/v11/configuring-npm/package-json#devengines
|
|
86
|
+
|
|
87
|
+
[PostCSS]: https://postcss.org
|
|
88
|
+
[plugin]: https://postcss.org/docs/postcss-plugins
|
|
89
|
+
[`@import`]: https://developer.mozilla.org/docs/Web/CSS/Reference/At-rules/@import
|
|
90
|
+
[glob]: https://globster.xyz
|
package/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { basedir, glob, readFile, raw } from "#utils"
|
|
2
|
+
|
|
3
|
+
import metadata from "./package.json" with { type: "json" }
|
|
4
|
+
const {name} = metadata
|
|
5
|
+
|
|
6
|
+
export const importGlob = options => ({
|
|
7
|
+
postcssPlugin: name,
|
|
8
|
+
AtRule: {
|
|
9
|
+
async import(node, { parse, result }) {
|
|
10
|
+
options ??= {}
|
|
11
|
+
options.globstar ??= true
|
|
12
|
+
|
|
13
|
+
const parent = result.opts.from
|
|
14
|
+
const path = node.source.input.file ?? parent
|
|
15
|
+
const pattern = raw(node.params)
|
|
16
|
+
options.cwd ??= basedir(path)
|
|
17
|
+
|
|
18
|
+
const read = path => readFile(`${options.cwd}/${path}`)
|
|
19
|
+
.then(parse)
|
|
20
|
+
.catch(result.error)
|
|
21
|
+
|
|
22
|
+
const css = await glob(pattern, options, read)
|
|
23
|
+
node.replaceWith(...css)
|
|
24
|
+
|
|
25
|
+
const metadata = css.map(file => ({
|
|
26
|
+
type: "dependency",
|
|
27
|
+
plugin: name,
|
|
28
|
+
file,
|
|
29
|
+
parent,
|
|
30
|
+
}))
|
|
31
|
+
|
|
32
|
+
result.messages.push(...metadata)
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
importGlob.postcss = true
|
|
38
|
+
export default importGlob
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.1.0",
|
|
3
|
+
"name": "postcss-import-glob",
|
|
4
|
+
"description": "PostCSS plugin to inline CSS @imports, with support for glob patterns.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"plugin",
|
|
7
|
+
"css",
|
|
8
|
+
"postcss",
|
|
9
|
+
"postcss-plugin",
|
|
10
|
+
"import",
|
|
11
|
+
"@import",
|
|
12
|
+
"glob",
|
|
13
|
+
"glob-pattern",
|
|
14
|
+
"styles",
|
|
15
|
+
"stylesheets"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://npm.im/postcss-import-glob",
|
|
18
|
+
"repository": "danielbayley/postcss-import-glob",
|
|
19
|
+
"bugs": "https://github.com/danielbayley/postcss-import-glob/issues",
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Daniel Bayley",
|
|
22
|
+
"email": "daniel.bayley@me.com",
|
|
23
|
+
"url": "danielbayley.dev"
|
|
24
|
+
},
|
|
25
|
+
"funding": "https://github.com/danielbayley/postcss-import-glob?sponsor=1",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"type": "module",
|
|
28
|
+
"exports": "./index.js",
|
|
29
|
+
"files": [
|
|
30
|
+
"./index.js"
|
|
31
|
+
],
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22",
|
|
37
|
+
"pnpm": ">=10"
|
|
38
|
+
},
|
|
39
|
+
"devEngines": {
|
|
40
|
+
"runtime": {
|
|
41
|
+
"name": "node",
|
|
42
|
+
"version": ">=22"
|
|
43
|
+
},
|
|
44
|
+
"packageManager": [
|
|
45
|
+
{
|
|
46
|
+
"name": "pnpm",
|
|
47
|
+
"version": ">=10"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"name": "npm"
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"peerDependencies": {
|
|
55
|
+
"postcss": "^8.5.8"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"postcss": "^8.5.8",
|
|
59
|
+
"knip": "^5.86.0",
|
|
60
|
+
"publint": "^0.3.18",
|
|
61
|
+
"yaml": "^2.8.2"
|
|
62
|
+
},
|
|
63
|
+
"scripts": {
|
|
64
|
+
"test": "node --test --experimental-test-coverage test/*.js",
|
|
65
|
+
"prerelease": "git stash --include-untracked --keep-index && pnpm prepare",
|
|
66
|
+
"release": "pnpm version --force --no-git-tag-version",
|
|
67
|
+
"postrelease": "pnpm publish",
|
|
68
|
+
"version": "sed -i \"\" -E \"s/^(version: *)$npm_old_version\\$/\\\\1$npm_new_version/\" package.yaml && git commit --message $npm_new_version package.yaml && git tag --annotate $npm_new_version --message v$npm_new_version && git push --follow-tags",
|
|
69
|
+
"watch": "pnpm test --watch",
|
|
70
|
+
"clean": "git clean -X --force",
|
|
71
|
+
"zap": "pnpm clean && rm -rf node_modules || true",
|
|
72
|
+
"reinstall": "pnpm zap && pnpm install"
|
|
73
|
+
}
|
|
74
|
+
}
|