@prunellejs/tailwind 0.0.0-stage → 0.6.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/llms.txt +32 -0
- package/package.json +24 -4
- package/src/index.ts +68 -0
- package/README.md +0 -3
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.
|
|
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.6.0",
|
|
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.6.0"
|
|
25
|
+
}
|
|
26
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
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, serviceKey } from 'prunelle/config'
|
|
9
|
+
|
|
10
|
+
const UI_KUI_LAYER_SERVICE = serviceKey<boolean>('prunelle.ui.kuiLayer')
|
|
11
|
+
// Declares @layer kui after Tailwind's base Preflight and before utilities so utilities override @prunellejs/ui without Preflight wiping component styles.
|
|
12
|
+
const KUI_LAYER_ORDER_TAG = '<style>@layer properties,theme,base,kui,components,utilities;</style>'
|
|
13
|
+
|
|
14
|
+
export interface TailwindPluginOptions {
|
|
15
|
+
/** Global stylesheet entry path relative to project root (default: 'src/app.css'). */
|
|
16
|
+
css?: string | undefined
|
|
17
|
+
/** Optional Bun CSS/Tailwind plugin override; auto-resolved from `bun-plugin-tailwind` when omitted. */
|
|
18
|
+
bunPlugin?: BunPlugin | undefined
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
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 }).'
|
|
22
|
+
|
|
23
|
+
function loadDefaultTailwindPlugin(root: string): BunPlugin | undefined {
|
|
24
|
+
for (const base of [join(root, 'package.json'), import.meta.url]) {
|
|
25
|
+
try {
|
|
26
|
+
const req = createRequire(base)
|
|
27
|
+
const mod = req('bun-plugin-tailwind') as BunPlugin | { default?: BunPlugin }
|
|
28
|
+
const plugin = typeof (mod as { default?: BunPlugin }).default === 'object'
|
|
29
|
+
? (mod as { default: BunPlugin }).default
|
|
30
|
+
: mod as BunPlugin
|
|
31
|
+
if (plugin !== undefined && typeof plugin.setup === 'function')
|
|
32
|
+
return plugin
|
|
33
|
+
}
|
|
34
|
+
catch {}
|
|
35
|
+
}
|
|
36
|
+
return undefined
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function tailwind(options: TailwindPluginOptions = {}): PrunellePlugin {
|
|
40
|
+
let warnedMissing = false
|
|
41
|
+
|
|
42
|
+
return definePlugin({
|
|
43
|
+
name: '@prunellejs/tailwind',
|
|
44
|
+
after: ['@prunellejs/ui'],
|
|
45
|
+
css: [options.css ?? 'src/app.css'],
|
|
46
|
+
build(ctx) {
|
|
47
|
+
if (ctx.inject(UI_KUI_LAYER_SERVICE) === true)
|
|
48
|
+
ctx.addHead(KUI_LAYER_ORDER_TAG)
|
|
49
|
+
},
|
|
50
|
+
bunPlugins: options.bunPlugin !== undefined
|
|
51
|
+
? [options.bunPlugin]
|
|
52
|
+
: ({ root }) => {
|
|
53
|
+
const auto = loadDefaultTailwindPlugin(root)
|
|
54
|
+
if (auto === undefined) {
|
|
55
|
+
if (!warnedMissing) {
|
|
56
|
+
warnedMissing = true
|
|
57
|
+
console.warn(MISSING_PLUGIN_MESSAGE)
|
|
58
|
+
}
|
|
59
|
+
return []
|
|
60
|
+
}
|
|
61
|
+
return [auto]
|
|
62
|
+
},
|
|
63
|
+
check(ctx) {
|
|
64
|
+
if (options.bunPlugin === undefined && loadDefaultTailwindPlugin(ctx.root) === undefined)
|
|
65
|
+
ctx.error(MISSING_PLUGIN_MESSAGE)
|
|
66
|
+
},
|
|
67
|
+
})
|
|
68
|
+
}
|
package/README.md
DELETED