@cwcss/crosswind 0.1.5 → 0.2.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 +52 -0
- package/dist/bin/cli.js +14615 -0
- package/dist/build.d.ts +24 -0
- package/dist/config.d.ts +5 -0
- package/dist/generator.d.ts +31 -0
- package/dist/index.d.ts +10 -0
- package/dist/parser.d.ts +42 -0
- package/dist/plugin.d.ts +22 -0
- package/dist/preflight-forms.d.ts +5 -0
- package/dist/preflight.d.ts +2 -0
- package/dist/rules-advanced.d.ts +27 -0
- package/dist/rules-effects.d.ts +25 -0
- package/dist/rules-forms.d.ts +7 -0
- package/dist/rules-grid.d.ts +13 -0
- package/dist/rules-interactivity.d.ts +41 -0
- package/dist/rules-layout.d.ts +26 -0
- package/dist/rules-transforms.d.ts +33 -0
- package/dist/rules-typography.d.ts +41 -0
- package/dist/rules.d.ts +39 -0
- package/dist/scanner.d.ts +18 -0
- package/dist/src/index.js +12848 -0
- package/dist/transformer-compile-class.d.ts +37 -0
- package/{src/types.ts → dist/types.d.ts} +17 -86
- package/package.json +2 -16
- package/PLUGIN.md +0 -235
- package/benchmark/framework-comparison.bench.ts +0 -850
- package/bin/cli.ts +0 -365
- package/bin/crosswind +0 -0
- package/bin/headwind +0 -0
- package/build.ts +0 -8
- package/crosswind.config.ts +0 -9
- package/example/comprehensive.html +0 -70
- package/example/index.html +0 -21
- package/example/output.css +0 -236
- package/examples/plugin/README.md +0 -112
- package/examples/plugin/build.ts +0 -32
- package/examples/plugin/src/index.html +0 -34
- package/examples/plugin/src/index.ts +0 -7
- package/headwind +0 -2
- package/src/build.ts +0 -101
- package/src/config.ts +0 -529
- package/src/generator.ts +0 -2173
- package/src/index.ts +0 -10
- package/src/parser.ts +0 -1471
- package/src/plugin.ts +0 -118
- package/src/preflight-forms.ts +0 -229
- package/src/preflight.ts +0 -388
- package/src/rules-advanced.ts +0 -477
- package/src/rules-effects.ts +0 -461
- package/src/rules-forms.ts +0 -103
- package/src/rules-grid.ts +0 -241
- package/src/rules-interactivity.ts +0 -525
- package/src/rules-layout.ts +0 -385
- package/src/rules-transforms.ts +0 -412
- package/src/rules-typography.ts +0 -486
- package/src/rules.ts +0 -809
- package/src/scanner.ts +0 -84
- package/src/transformer-compile-class.ts +0 -275
- package/test/advanced-features.test.ts +0 -911
- package/test/arbitrary.test.ts +0 -396
- package/test/attributify.test.ts +0 -592
- package/test/bracket-syntax.test.ts +0 -1133
- package/test/build.test.ts +0 -99
- package/test/colors.test.ts +0 -934
- package/test/flexbox.test.ts +0 -669
- package/test/generator.test.ts +0 -597
- package/test/grid.test.ts +0 -584
- package/test/layout.test.ts +0 -404
- package/test/modifiers.test.ts +0 -417
- package/test/parser.test.ts +0 -564
- package/test/performance-regression.test.ts +0 -376
- package/test/performance.test.ts +0 -568
- package/test/plugin.test.ts +0 -160
- package/test/scanner.test.ts +0 -94
- package/test/sizing.test.ts +0 -481
- package/test/spacing.test.ts +0 -394
- package/test/transformer-compile-class.test.ts +0 -287
- package/test/transforms.test.ts +0 -448
- package/test/typography.test.ts +0 -632
- package/test/variants-form-states.test.ts +0 -225
- package/test/variants-group-peer.test.ts +0 -66
- package/test/variants-media.test.ts +0 -213
- package/test/variants-positional.test.ts +0 -58
- package/test/variants-pseudo-elements.test.ts +0 -47
- package/test/variants-state.test.ts +0 -62
- package/tsconfig.json +0 -18
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { CrosswindConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Extract compile class markers from content
|
|
4
|
+
*/
|
|
5
|
+
export declare function extractCompileClasses(content: string, options?: CompileClassOptions): Map<string, string[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Transform content by replacing compile markers with generated class names
|
|
8
|
+
*/
|
|
9
|
+
export declare function transformContent(content: string, compiledClassMap: Map<string, string>, options?: CompileClassOptions): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generate class names for compiled classes
|
|
12
|
+
*/
|
|
13
|
+
export declare function generateCompiledClassNames(compiledClasses: Map<string, string[]>, options?: CompileClassOptions): Map<string, string>;
|
|
14
|
+
export declare interface CompileClassOptions {
|
|
15
|
+
trigger?: string
|
|
16
|
+
classPrefix?: string
|
|
17
|
+
hashFn?: (content: string) => string
|
|
18
|
+
layer?: string
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Main transformer class
|
|
22
|
+
*/
|
|
23
|
+
export declare class CompileClassTransformer {
|
|
24
|
+
private compiledClasses: any;
|
|
25
|
+
private classNameMap: any;
|
|
26
|
+
private options: CompileClassOptions;
|
|
27
|
+
constructor(options?: CompileClassOptions);
|
|
28
|
+
processFile(content: string): { content: string, hasChanges: boolean };
|
|
29
|
+
getCompiledClasses(): Map<string, { className: string, utilities: string[] }>;
|
|
30
|
+
generateCSS(config: CrosswindConfig, generator: any): string;
|
|
31
|
+
reset(): void;
|
|
32
|
+
getStats(): {
|
|
33
|
+
totalGroups: number
|
|
34
|
+
totalUtilities: number
|
|
35
|
+
averageUtilitiesPerGroup: number
|
|
36
|
+
};
|
|
37
|
+
}
|
|
@@ -1,68 +1,20 @@
|
|
|
1
|
-
export interface CompileClassConfig {
|
|
2
|
-
/**
|
|
3
|
-
* Enable compile class transformer
|
|
4
|
-
* @default false
|
|
5
|
-
*/
|
|
1
|
+
export declare interface CompileClassConfig {
|
|
6
2
|
enabled?: boolean
|
|
7
|
-
/**
|
|
8
|
-
* Trigger string to mark classes for compilation
|
|
9
|
-
* @default ':hw:'
|
|
10
|
-
*/
|
|
11
3
|
trigger?: string
|
|
12
|
-
/**
|
|
13
|
-
* Prefix for generated class names
|
|
14
|
-
* @default 'hw-'
|
|
15
|
-
*/
|
|
16
4
|
classPrefix?: string
|
|
17
|
-
/**
|
|
18
|
-
* Layer name for compiled classes
|
|
19
|
-
* @default 'shortcuts'
|
|
20
|
-
*/
|
|
21
5
|
layer?: string
|
|
22
6
|
}
|
|
23
|
-
|
|
24
|
-
export interface AttributifyConfig {
|
|
25
|
-
/**
|
|
26
|
-
* Enable attributify mode
|
|
27
|
-
* Allows using HTML attributes instead of class names
|
|
28
|
-
* e.g., <div hw-flex hw-bg="blue-500">
|
|
29
|
-
* @default false
|
|
30
|
-
*/
|
|
7
|
+
export declare interface AttributifyConfig {
|
|
31
8
|
enabled?: boolean
|
|
32
|
-
/**
|
|
33
|
-
* Prefix for attributify attributes (to avoid conflicts with HTML attributes)
|
|
34
|
-
* e.g., with prefix 'hw-': <div hw-flex hw-bg="blue-500">
|
|
35
|
-
* @default 'hw-'
|
|
36
|
-
*/
|
|
37
9
|
prefix?: string
|
|
38
|
-
/**
|
|
39
|
-
* Attributes to ignore (won't be treated as utilities)
|
|
40
|
-
* @default ['class', 'className', 'style', 'id', ...]
|
|
41
|
-
*/
|
|
42
10
|
ignoreAttributes?: string[]
|
|
43
11
|
}
|
|
44
|
-
|
|
45
|
-
export interface BracketSyntaxConfig {
|
|
46
|
-
/**
|
|
47
|
-
* Enable bracket/grouped syntax
|
|
48
|
-
* Allows grouping utilities like: flex[col jc-center ai-center] or text[white 2rem 700]
|
|
49
|
-
* @default false
|
|
50
|
-
*/
|
|
12
|
+
export declare interface BracketSyntaxConfig {
|
|
51
13
|
enabled?: boolean
|
|
52
|
-
/**
|
|
53
|
-
* Enable colon syntax for simple values
|
|
54
|
-
* e.g., bg:black, w:100%, text:white
|
|
55
|
-
* @default false
|
|
56
|
-
*/
|
|
57
14
|
colonSyntax?: boolean
|
|
58
|
-
/**
|
|
59
|
-
* Mapping of shorthand abbreviations to full utility names
|
|
60
|
-
* e.g., { 'jc': 'justify', 'ai': 'items', 'col': 'col' }
|
|
61
|
-
*/
|
|
62
15
|
aliases?: Record<string, string>
|
|
63
16
|
}
|
|
64
|
-
|
|
65
|
-
export interface CrosswindConfig {
|
|
17
|
+
export declare interface CrosswindConfig {
|
|
66
18
|
content: string[]
|
|
67
19
|
output: string
|
|
68
20
|
minify: boolean
|
|
@@ -79,11 +31,9 @@ export interface CrosswindConfig {
|
|
|
79
31
|
compileClass?: CompileClassConfig
|
|
80
32
|
attributify?: AttributifyConfig
|
|
81
33
|
bracketSyntax?: BracketSyntaxConfig
|
|
82
|
-
/** Generate :root CSS variables from theme colors (e.g., --monokai-bg: #2d2a2e) */
|
|
83
34
|
cssVariables?: boolean
|
|
84
35
|
}
|
|
85
|
-
|
|
86
|
-
export interface Theme {
|
|
36
|
+
export declare interface Theme {
|
|
87
37
|
colors: Record<string, string | Record<string, string>>
|
|
88
38
|
spacing: Record<string, string>
|
|
89
39
|
fontSize: Record<string, [string, { lineHeight: string }]>
|
|
@@ -91,25 +41,20 @@ export interface Theme {
|
|
|
91
41
|
screens: Record<string, string>
|
|
92
42
|
borderRadius: Record<string, string>
|
|
93
43
|
boxShadow: Record<string, string>
|
|
94
|
-
/** Extend theme values without replacing defaults */
|
|
95
44
|
extend?: Partial<Omit<Theme, 'extend'>>
|
|
96
45
|
}
|
|
97
|
-
|
|
98
|
-
export interface VariantConfig {
|
|
46
|
+
export declare interface VariantConfig {
|
|
99
47
|
'responsive': boolean
|
|
100
48
|
'hover': boolean
|
|
101
49
|
'focus': boolean
|
|
102
50
|
'active': boolean
|
|
103
51
|
'disabled': boolean
|
|
104
52
|
'dark': boolean
|
|
105
|
-
// Group/Peer
|
|
106
53
|
'group': boolean
|
|
107
54
|
'peer': boolean
|
|
108
|
-
// Pseudo-elements
|
|
109
55
|
'before': boolean
|
|
110
56
|
'after': boolean
|
|
111
57
|
'marker': boolean
|
|
112
|
-
// Pseudo-classes - Basic
|
|
113
58
|
'first': boolean
|
|
114
59
|
'last': boolean
|
|
115
60
|
'odd': boolean
|
|
@@ -120,7 +65,6 @@ export interface VariantConfig {
|
|
|
120
65
|
'checked': boolean
|
|
121
66
|
'focus-within': boolean
|
|
122
67
|
'focus-visible': boolean
|
|
123
|
-
// Pseudo-classes - Form states
|
|
124
68
|
'placeholder': boolean
|
|
125
69
|
'selection': boolean
|
|
126
70
|
'file': boolean
|
|
@@ -129,7 +73,6 @@ export interface VariantConfig {
|
|
|
129
73
|
'invalid': boolean
|
|
130
74
|
'read-only': boolean
|
|
131
75
|
'autofill': boolean
|
|
132
|
-
// Pseudo-classes - Additional states
|
|
133
76
|
'open': boolean
|
|
134
77
|
'closed': boolean
|
|
135
78
|
'empty': boolean
|
|
@@ -139,49 +82,38 @@ export interface VariantConfig {
|
|
|
139
82
|
'indeterminate': boolean
|
|
140
83
|
'default': boolean
|
|
141
84
|
'optional': boolean
|
|
142
|
-
// Media
|
|
143
85
|
'print': boolean
|
|
144
|
-
// Direction
|
|
145
86
|
'rtl': boolean
|
|
146
87
|
'ltr': boolean
|
|
147
|
-
// Motion
|
|
148
88
|
'motion-safe': boolean
|
|
149
89
|
'motion-reduce': boolean
|
|
150
|
-
// Contrast
|
|
151
90
|
'contrast-more': boolean
|
|
152
91
|
'contrast-less': boolean
|
|
153
92
|
}
|
|
154
|
-
|
|
155
|
-
export interface ParsedClass {
|
|
93
|
+
export declare interface ParsedClass {
|
|
156
94
|
raw: string
|
|
157
95
|
variants: string[]
|
|
158
96
|
utility: string
|
|
159
97
|
value?: string
|
|
160
98
|
important: boolean
|
|
161
99
|
arbitrary: boolean
|
|
162
|
-
typeHint?: string
|
|
100
|
+
typeHint?: string
|
|
163
101
|
}
|
|
164
|
-
|
|
165
|
-
export interface CSSRule {
|
|
102
|
+
export declare interface CSSRule {
|
|
166
103
|
selector: string
|
|
167
104
|
properties: Record<string, string>
|
|
168
105
|
mediaQuery?: string
|
|
169
|
-
childSelector?: string
|
|
106
|
+
childSelector?: string
|
|
170
107
|
}
|
|
171
|
-
|
|
172
|
-
export interface UtilityRuleResult {
|
|
108
|
+
export declare interface UtilityRuleResult {
|
|
173
109
|
properties: Record<string, string>
|
|
174
110
|
childSelector?: string
|
|
175
|
-
pseudoElement?: string
|
|
111
|
+
pseudoElement?: string
|
|
176
112
|
}
|
|
177
|
-
|
|
178
|
-
export type CustomRule = [RegExp, (match: RegExpMatchArray) => Record<string, string> | undefined]
|
|
179
|
-
|
|
180
|
-
export interface Preflight {
|
|
113
|
+
export declare interface Preflight {
|
|
181
114
|
getCSS: () => string
|
|
182
115
|
}
|
|
183
|
-
|
|
184
|
-
export interface Preset {
|
|
116
|
+
export declare interface Preset {
|
|
185
117
|
name: string
|
|
186
118
|
theme?: Partial<Theme>
|
|
187
119
|
rules?: CustomRule[]
|
|
@@ -189,9 +121,8 @@ export interface Preset {
|
|
|
189
121
|
variants?: Partial<VariantConfig>
|
|
190
122
|
preflights?: Preflight[]
|
|
191
123
|
}
|
|
192
|
-
|
|
193
|
-
type DeepPartial<T> = {
|
|
124
|
+
export type CustomRule = [RegExp, (_match: RegExpMatchArray) => Record<string, string> | undefined]
|
|
125
|
+
declare type DeepPartial<T> = {
|
|
194
126
|
[P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P]
|
|
195
127
|
}
|
|
196
|
-
|
|
197
|
-
export type CrosswindOptions = DeepPartial<CrosswindConfig>
|
|
128
|
+
export type CrosswindOptions = DeepPartial<CrosswindConfig>
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cwcss/crosswind",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"description": "A performant Utility-First CSS framework. Similar to Tailwind or UnoCSS.",
|
|
6
6
|
"author": "Chris Breuer <chris@stacksjs.org>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"module": "./dist/index.js",
|
|
38
38
|
"types": "./dist/index.d.ts",
|
|
39
39
|
"bin": {
|
|
40
|
-
"crosswind": "./dist/
|
|
40
|
+
"crosswind": "./dist/cli.js"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"README.md",
|
|
@@ -72,21 +72,7 @@
|
|
|
72
72
|
"@stacksjs/clapp": "^0.2.0",
|
|
73
73
|
"bunfig": "^0.15.0"
|
|
74
74
|
},
|
|
75
|
-
"overrides": {
|
|
76
|
-
"unconfig": "0.3.10"
|
|
77
|
-
},
|
|
78
75
|
"lint-staged": {
|
|
79
76
|
"*.{js,ts}": "bunx --bun pickier run --mode lint --fix"
|
|
80
|
-
},
|
|
81
|
-
"devDependencies": {
|
|
82
|
-
"@tailwindcss/node": "^4.1.14",
|
|
83
|
-
"@tailwindcss/postcss": "^4.1",
|
|
84
|
-
"@tailwindcss/vite": "^4.1",
|
|
85
|
-
"@unocss/core": "^66.5.4",
|
|
86
|
-
"@unocss/preset-wind": "^66.5.4",
|
|
87
|
-
"mitata": "^1.0.34",
|
|
88
|
-
"postcss": "^8.5.6",
|
|
89
|
-
"tailwindcss": "^3",
|
|
90
|
-
"tailwindcss-v4": "npm:tailwindcss@^4"
|
|
91
77
|
}
|
|
92
78
|
}
|
package/PLUGIN.md
DELETED
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
# Crosswind Bun Plugin
|
|
2
|
-
|
|
3
|
-
A Bun plugin that automatically generates and injects Crosswind CSS into your HTML files during the build process.
|
|
4
|
-
|
|
5
|
-
## Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
bun add @cwcss/crosswind
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
**1. Create your HTML file** (`src/template.html`):
|
|
14
|
-
|
|
15
|
-
```html
|
|
16
|
-
<!DOCTYPE html>
|
|
17
|
-
<html>
|
|
18
|
-
<head>
|
|
19
|
-
<title>My App</title>
|
|
20
|
-
</head>
|
|
21
|
-
<body>
|
|
22
|
-
<div class="flex items-center p-4 bg-blue-500 text-white rounded-lg">
|
|
23
|
-
<h1 class="text-2xl font-bold">Hello Crosswind!</h1>
|
|
24
|
-
</div>
|
|
25
|
-
</body>
|
|
26
|
-
</html>
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
**2. Import it in your TypeScript** (`src/index.ts`):
|
|
30
|
-
|
|
31
|
-
```typescript
|
|
32
|
-
import template from './template.html'
|
|
33
|
-
|
|
34
|
-
// The HTML now has Crosswind CSS injected
|
|
35
|
-
document.body.innerHTML = template
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
**3. Build with the plugin**:
|
|
39
|
-
|
|
40
|
-
```typescript
|
|
41
|
-
import { plugin } from '@cwcss/crosswind'
|
|
42
|
-
|
|
43
|
-
await Bun.build({
|
|
44
|
-
entrypoints: ['./src/index.ts'],
|
|
45
|
-
outdir: './dist',
|
|
46
|
-
plugins: [plugin()],
|
|
47
|
-
})
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
The plugin will automatically:
|
|
51
|
-
|
|
52
|
-
- Scan the HTML for utility classes
|
|
53
|
-
- Generate CSS for those classes
|
|
54
|
-
- Inject the CSS into the `<head>` section
|
|
55
|
-
|
|
56
|
-
## Configuration
|
|
57
|
-
|
|
58
|
-
### Basic Configuration
|
|
59
|
-
|
|
60
|
-
```typescript
|
|
61
|
-
import { plugin } from '@cwcss/crosswind'
|
|
62
|
-
|
|
63
|
-
await Bun.build({
|
|
64
|
-
entrypoints: ['./src/index.ts'],
|
|
65
|
-
outdir: './dist',
|
|
66
|
-
plugins: [
|
|
67
|
-
plugin({
|
|
68
|
-
includePreflight: true, // Include CSS reset (default: true)
|
|
69
|
-
}),
|
|
70
|
-
],
|
|
71
|
-
})
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Custom Theme
|
|
75
|
-
|
|
76
|
-
```typescript
|
|
77
|
-
import { plugin } from '@cwcss/crosswind'
|
|
78
|
-
|
|
79
|
-
await Bun.build({
|
|
80
|
-
entrypoints: ['./src/index.ts'],
|
|
81
|
-
outdir: './dist',
|
|
82
|
-
plugins: [
|
|
83
|
-
plugin({
|
|
84
|
-
config: {
|
|
85
|
-
minify: true,
|
|
86
|
-
theme: {
|
|
87
|
-
colors: {
|
|
88
|
-
primary: '#3b82f6',
|
|
89
|
-
secondary: '#10b981',
|
|
90
|
-
danger: '#ef4444',
|
|
91
|
-
},
|
|
92
|
-
spacing: {
|
|
93
|
-
18: '4.5rem',
|
|
94
|
-
88: '22rem',
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
shortcuts: {
|
|
98
|
-
btn: 'px-4 py-2 rounded bg-primary text-white hover:bg-blue-600',
|
|
99
|
-
card: 'p-6 bg-white rounded-lg shadow-md',
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
}),
|
|
103
|
-
],
|
|
104
|
-
})
|
|
105
|
-
```
|
|
106
|
-
|
|
107
|
-
### Advanced Configuration
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
import { plugin } from '@cwcss/crosswind'
|
|
111
|
-
|
|
112
|
-
await Bun.build({
|
|
113
|
-
entrypoints: ['./src/index.ts'],
|
|
114
|
-
outdir: './dist',
|
|
115
|
-
plugins: [
|
|
116
|
-
plugin({
|
|
117
|
-
config: {
|
|
118
|
-
minify: true,
|
|
119
|
-
safelist: ['bg-red-500', 'text-green-500'], // Always include these
|
|
120
|
-
blocklist: ['debug-*'], // Never include these
|
|
121
|
-
theme: {
|
|
122
|
-
colors: {
|
|
123
|
-
brand: {
|
|
124
|
-
50: '#f0f9ff',
|
|
125
|
-
100: '#e0f2fe',
|
|
126
|
-
500: '#0ea5e9',
|
|
127
|
-
900: '#0c4a6e',
|
|
128
|
-
},
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
shortcuts: {
|
|
132
|
-
'btn-primary': 'px-4 py-2 rounded bg-brand-500 text-white hover:bg-brand-600',
|
|
133
|
-
},
|
|
134
|
-
},
|
|
135
|
-
includePreflight: true,
|
|
136
|
-
}),
|
|
137
|
-
],
|
|
138
|
-
})
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
## API Reference
|
|
142
|
-
|
|
143
|
-
### `plugin(options?)`
|
|
144
|
-
|
|
145
|
-
Creates a Crosswind Bun plugin instance.
|
|
146
|
-
|
|
147
|
-
#### Options
|
|
148
|
-
|
|
149
|
-
- **`config`** (`Partial<CrosswindConfig>`) - Custom Crosswind configuration
|
|
150
|
-
- `minify` - Minify the generated CSS
|
|
151
|
-
- `theme` - Custom theme (colors, spacing, fonts, etc.)
|
|
152
|
-
- `shortcuts` - Utility class shortcuts
|
|
153
|
-
- `safelist` - Classes to always include
|
|
154
|
-
- `blocklist` - Classes to never include
|
|
155
|
-
- `variants` - Enable/disable variants
|
|
156
|
-
- And more...
|
|
157
|
-
|
|
158
|
-
- **`includePreflight`** (`boolean`) - Include preflight CSS (default: `true`)
|
|
159
|
-
|
|
160
|
-
## How It Works
|
|
161
|
-
|
|
162
|
-
1. The plugin registers an `onLoad` handler for `.html` files
|
|
163
|
-
2. When Bun encounters an HTML import, the plugin intercepts it
|
|
164
|
-
3. It extracts all utility classes from the HTML using Crosswind's parser
|
|
165
|
-
4. It generates CSS for those classes using Crosswind's generator
|
|
166
|
-
5. The CSS is injected into the `<head>` section
|
|
167
|
-
6. The processed HTML is returned to the bundle
|
|
168
|
-
|
|
169
|
-
## Use Cases
|
|
170
|
-
|
|
171
|
-
- **SPAs**: Import HTML templates with automatic CSS generation
|
|
172
|
-
- **Web Components**: Load component templates with scoped styles
|
|
173
|
-
- **Static Sites**: Process HTML pages during build
|
|
174
|
-
- **Email Templates**: Generate inline CSS for email HTML
|
|
175
|
-
|
|
176
|
-
## Examples
|
|
177
|
-
|
|
178
|
-
See the [examples/plugin](./examples/plugin) directory for a complete working example.
|
|
179
|
-
|
|
180
|
-
## Comparison with CLI
|
|
181
|
-
|
|
182
|
-
| Feature | Plugin | CLI |
|
|
183
|
-
|---------|--------|-----|
|
|
184
|
-
| Automatic CSS generation | ✅ | ✅ |
|
|
185
|
-
| Watches files | ✅ (via Bun) | ✅ |
|
|
186
|
-
| Injects CSS | ✅ | ❌ |
|
|
187
|
-
| Separate CSS file | ❌ | ✅ |
|
|
188
|
-
| Build integration | ✅ | ❌ |
|
|
189
|
-
| Standalone usage | ❌ | ✅ |
|
|
190
|
-
|
|
191
|
-
## Performance
|
|
192
|
-
|
|
193
|
-
The plugin is highly performant:
|
|
194
|
-
|
|
195
|
-
- Processes 1000 utilities in ~7ms
|
|
196
|
-
- Minimal overhead in build process
|
|
197
|
-
- Lazy loading - only processes imported HTML files
|
|
198
|
-
|
|
199
|
-
## TypeScript Support
|
|
200
|
-
|
|
201
|
-
The plugin is fully typed. Import the types:
|
|
202
|
-
|
|
203
|
-
```typescript
|
|
204
|
-
import type { CrosswindPluginOptions } from '@cwcss/crosswind'
|
|
205
|
-
|
|
206
|
-
const options: CrosswindPluginOptions = {
|
|
207
|
-
config: {
|
|
208
|
-
minify: true,
|
|
209
|
-
},
|
|
210
|
-
}
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
## Configuration File
|
|
214
|
-
|
|
215
|
-
The plugin also respects `crosswind.config.ts` in your project root:
|
|
216
|
-
|
|
217
|
-
```typescript
|
|
218
|
-
// crosswind.config.ts
|
|
219
|
-
import type { CrosswindOptions } from '@cwcss/crosswind'
|
|
220
|
-
|
|
221
|
-
export default {
|
|
222
|
-
minify: true,
|
|
223
|
-
theme: {
|
|
224
|
-
colors: {
|
|
225
|
-
primary: '#3b82f6',
|
|
226
|
-
},
|
|
227
|
-
},
|
|
228
|
-
} satisfies CrosswindOptions
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
The plugin will merge this config with any options passed to it.
|
|
232
|
-
|
|
233
|
-
## License
|
|
234
|
-
|
|
235
|
-
MIT
|