@prunellejs/tailwind 0.0.0-stage → 0.7.2
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 +21 -0
- package/llms.txt +32 -0
- package/package.json +24 -4
- package/src/index.ts +75 -0
- package/README.md +0 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kaynooo
|
|
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/llms.txt
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @prunellejs/tailwind Reference
|
|
2
|
+
|
|
3
|
+
> Tailwind CSS v4 integration plugin for Prunelle via `bun-plugin-tailwind`.
|
|
4
|
+
|
|
5
|
+
## Imports
|
|
6
|
+
|
|
7
|
+
- `@prunellejs/tailwind`: `tailwind(options?)`; type `TailwindPluginOptions`.
|
|
8
|
+
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
Install `tailwindcss` and `bun-plugin-tailwind` in your app (`bun add -d tailwindcss bun-plugin-tailwind`), then register `tailwind()` in `prunelle.config.ts`:
|
|
12
|
+
|
|
13
|
+
- `css`: global stylesheet entry path relative to project root (default `'src/app.css'`).
|
|
14
|
+
- `bunPlugin`: optional `BunPlugin` override (auto-resolved from `bun-plugin-tailwind` when omitted).
|
|
15
|
+
- `prunelle check`: reports an error if `bun-plugin-tailwind` cannot be resolved and no `bunPlugin` was passed. An installed `bun-plugin-tailwind` that throws while loading fails the build with its own error as `cause`.
|
|
16
|
+
|
|
17
|
+
## Snippets
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
// prunelle.config.ts
|
|
21
|
+
import { defineConfig } from 'prunelle/config'
|
|
22
|
+
import { tailwind } from '@prunellejs/tailwind'
|
|
23
|
+
|
|
24
|
+
export default defineConfig({
|
|
25
|
+
plugins: [tailwind()], // defaults to css: 'src/app.css'
|
|
26
|
+
})
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
/* src/app.css */
|
|
31
|
+
@import "tailwindcss";
|
|
32
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prunellejs/tailwind",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"description": "Tailwind CSS v4 integration plugin for Prunelle",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"sideEffects": false,
|
|
8
|
+
"files": [
|
|
9
|
+
"src",
|
|
10
|
+
"llms.txt"
|
|
11
|
+
],
|
|
12
|
+
"exports": {
|
|
13
|
+
".": "./src/index.ts"
|
|
14
|
+
},
|
|
15
|
+
"engines": {
|
|
16
|
+
"bun": ">=1.4.0"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/Kayno0o/prunelle",
|
|
21
|
+
"directory": "packages/plugin-tailwind"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"prunelle": "^0.7.2"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// @prunellejs/tailwind — opt-in CSS & Tailwind v4 plugin using PrunellePlugin.bunPlugins + PrunellePlugin.css.
|
|
2
|
+
// Auto-loads `bun-plugin-tailwind` from the app root when `bunPlugin` is omitted.
|
|
3
|
+
|
|
4
|
+
import type { BunPlugin } from 'bun'
|
|
5
|
+
import type { PrunellePlugin } from 'prunelle/config'
|
|
6
|
+
import { createRequire } from 'node:module'
|
|
7
|
+
import { join } from 'node:path'
|
|
8
|
+
import { definePlugin, UI_KUI_LAYER_SERVICE } from 'prunelle/config'
|
|
9
|
+
|
|
10
|
+
// Declares @layer kui after Tailwind's base Preflight and before utilities so utilities override @prunellejs/ui without Preflight wiping component styles.
|
|
11
|
+
const KUI_LAYER_ORDER_TAG = '<style>@layer properties,theme,base,kui,components,utilities;</style>'
|
|
12
|
+
|
|
13
|
+
export interface TailwindPluginOptions {
|
|
14
|
+
/** Global stylesheet entry path relative to project root (default: 'src/app.css'). */
|
|
15
|
+
css?: string | undefined
|
|
16
|
+
/** Optional Bun CSS/Tailwind plugin override; auto-resolved from `bun-plugin-tailwind` when omitted. */
|
|
17
|
+
bunPlugin?: BunPlugin | undefined
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const MISSING_PLUGIN_MESSAGE = '@prunellejs/tailwind: "bun-plugin-tailwind" could not be resolved; CSS will not be processed by Tailwind. Install it with `bun add -d bun-plugin-tailwind` or pass tailwind({ bunPlugin }).'
|
|
21
|
+
|
|
22
|
+
function loadDefaultTailwindPlugin(root: string): BunPlugin | undefined {
|
|
23
|
+
for (const base of [join(root, 'package.json'), import.meta.url]) {
|
|
24
|
+
try {
|
|
25
|
+
const req = createRequire(base)
|
|
26
|
+
const mod = req('bun-plugin-tailwind') as BunPlugin | { default?: BunPlugin }
|
|
27
|
+
const plugin = typeof (mod as { default?: BunPlugin }).default === 'object'
|
|
28
|
+
? (mod as { default: BunPlugin }).default
|
|
29
|
+
: mod as BunPlugin
|
|
30
|
+
if (plugin !== undefined && typeof plugin.setup === 'function')
|
|
31
|
+
return plugin
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (!isMissingTailwindPlugin(err))
|
|
35
|
+
throw new Error(`@prunellejs/tailwind: "bun-plugin-tailwind" is installed but failed to load: ${err instanceof Error ? err.message : String(err)}. Reinstall it with \`bun add -d bun-plugin-tailwind\`, or pass tailwind({ bunPlugin }).`, { cause: err })
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return undefined
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Absent from this base, as opposed to installed and broken (a missing dependency of its own names another module).
|
|
42
|
+
function isMissingTailwindPlugin(err: unknown): boolean {
|
|
43
|
+
return err instanceof Error && err.message.startsWith('Cannot find module \'bun-plugin-tailwind\'')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function tailwind(options: TailwindPluginOptions = {}): PrunellePlugin {
|
|
47
|
+
let warnedMissing = false
|
|
48
|
+
|
|
49
|
+
return definePlugin({
|
|
50
|
+
name: '@prunellejs/tailwind',
|
|
51
|
+
after: ['@prunellejs/ui'],
|
|
52
|
+
css: [options.css ?? 'src/app.css'],
|
|
53
|
+
build(ctx) {
|
|
54
|
+
if (ctx.inject(UI_KUI_LAYER_SERVICE) === true)
|
|
55
|
+
ctx.addHead(KUI_LAYER_ORDER_TAG)
|
|
56
|
+
},
|
|
57
|
+
bunPlugins: options.bunPlugin !== undefined
|
|
58
|
+
? [options.bunPlugin]
|
|
59
|
+
: ({ root }) => {
|
|
60
|
+
const auto = loadDefaultTailwindPlugin(root)
|
|
61
|
+
if (auto === undefined) {
|
|
62
|
+
if (!warnedMissing) {
|
|
63
|
+
warnedMissing = true
|
|
64
|
+
console.warn(MISSING_PLUGIN_MESSAGE)
|
|
65
|
+
}
|
|
66
|
+
return []
|
|
67
|
+
}
|
|
68
|
+
return [auto]
|
|
69
|
+
},
|
|
70
|
+
check(ctx) {
|
|
71
|
+
if (options.bunPlugin === undefined && loadDefaultTailwindPlugin(ctx.root) === undefined)
|
|
72
|
+
ctx.error(MISSING_PLUGIN_MESSAGE)
|
|
73
|
+
},
|
|
74
|
+
})
|
|
75
|
+
}
|
package/README.md
DELETED