-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathoptions.ts
256 lines (222 loc) · 6.06 KB
/
options.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
import type { Extractor } from 'windicss/types/interfaces'
import type { LoadConfigurationOptions, WindiCssOptions } from '@windicss/config'
import type { TransformerFunction } from './transforms'
import type { TagNames } from './constants'
import type { WindiPluginUtils } from './createUtils'
export { WindiCssOptions }
export interface UserOptions {
/**
* Options for windicss/tailwindcss.
* Also accepts string as config file path.
*
* @default auto searching for `windi.config.ts` / `tailwind.config.js`
*/
config?: WindiCssOptions | string
/**
* A list of filename of paths to search of config files
*/
configFiles?: string[]
/**
* Safe class names to be always included.
*
* @deprecated define this field in the windicss.config.ts instead
*/
safelist?: string | (string | string[])[]
/**
* Class names to be always excluded.
*
* @deprecated define this field in the windicss.config.ts instead
*/
blocklist?: string | (string | string[])[]
/**
* Enabled windicss preflight (a.k.a TailwindCSS style reset)
*
* @deprecated define this field in the windicss.config.ts instead
* @default true
*/
preflight?: boolean | {
/**
* Enable all the preflight regardless the template
*
* @deprecated define this field in the windicss.config.ts instead
*/
enableAll?: boolean
/**
* Enable all the preflight regardless the template
*
* @deprecated define this field in the windicss.config.ts instead
*/
includeAll?: boolean
/**
* Safelist to always included
*
* @deprecated define this field in the windicss.config.ts instead
*/
safelist?: string | (string | string[])[]
/**
* Blocklist to always excluded
*
* @deprecated define this field in the windicss.config.ts instead
*/
blocklist?: string | (string | string[])[]
/**
* Alias for resolving preflight
*/
alias?: Record<string, TagNames>
/**
* @default true
* @deprecated define this field in the windicss.config.ts instead
*/
includeBase?: boolean
/**
* @default true
* @deprecated define this field in the windicss.config.ts instead
*/
includeGlobal?: boolean
/**
* @default true
* @deprecated define this field in the windicss.config.ts instead
*/
includePlugin?: boolean
}
/**
* File paths will be resolved against this directory.
*
* @default process.cwd
* @internal
*/
root?: string
/**
* Scan the files and extract the usage
*
* @default true
*/
scan?: boolean | {
/**
* Auto scan on startup
*
* @default true
*/
runOnStartup?: boolean
/**
* Directories to search for classnames
*
* @default 'src'
* @deprecated use `extract.include` in the windicss.config.ts instead
*/
dirs?: string | string[]
/**
* File extension to search for classnames
*
* @default 'html', 'vue', 'md', 'mdx', 'pug', 'jsx', 'tsx', 'svelte', 'js', 'ts'
* @deprecated use `extract.include` in the windicss.config.ts instead
*/
fileExtensions?: string | string[]
/**
* Exclude globs
*
* @default []
*/
exclude?: string | string[]
/**
* Include globs
*
* @default []
*/
include?: string | string[]
/**
* Transformers to apply before doing extraction
*
* @default []
*/
transformers?: TransformerFunction[]
}
/**
* Transform CSS for `@apply` directive
*
* @default true
*/
transformCSS?: boolean | 'pre' | 'post'
/**
* Transform groups like `hover:(bg-gray-100 font-medium)`
*
* @default true
*/
transformGroups?: boolean
/**
* Sort the genrate utilities
*
* @default true
*/
sortUtilities?: boolean
/**
* Callback before classes css generated
*/
onBeforeGenerate?: (ctx: { classesPending: Set<string>; tagsPending: Set<string> }) => void
/**
* Callback when classes and/or tags are generated/changed
*/
onGenerated?: (ctx: { classes: Set<string>; tags: Set<string> }) => void
/**
* Callback when the options are resolved. These are the plugin options and contain the windi config
*/
onOptionsResolved?: (options: ResolvedOptions) => ResolvedOptions | void | Promise<ResolvedOptions | void>
/**
* Callback when the windi config is resolved. Not to be confused with the options which are the top level way to
* configure the util package
*/
onConfigResolved?: (config: WindiCssOptions, configFilePath?: string) => WindiCssOptions | void | Promise<WindiCssOptions | void>
/**
* Callback when the utils is initialized
*/
onInitialized?: (utils: WindiPluginUtils) => void
}
export type WindiPluginUtilsOptions = Omit<LoadConfigurationOptions, 'config' | 'configFiles'> & {
/**
* Reuse existing plugin instance
*/
utils?: WindiPluginUtils
}
export interface ResolvedOptions {
config: WindiCssOptions
configFilePath: string | undefined
enableScan: boolean
enablePreflight: boolean
transformCSS: boolean | 'pre' | 'auto' | 'post'
transformGroups: boolean
scanOptions: {
fileExtensions: string[]
dirs: string[]
exclude: string[]
include: string[]
runOnStartup: boolean
transformers: TransformerFunction[]
extractors: Extractor[]
extraTransformTargets: {
css: (string | ((path: string) => boolean))[]
detect: (string | ((path: string) => boolean))[]
}
}
preflightOptions: {
includeBase: boolean
includeGlobal: boolean
includePlugin: boolean
includeAll: boolean
/**
* @deprecated use includeAll
*/
enableAll: boolean
safelist: Set<string>
blocklist: Set<string>
alias: Record<string, string>
}
root: string
sortUtilities: boolean
safelist: Set<string>
blocklist: Set<string>
onBeforeGenerate: UserOptions['onBeforeGenerate']
onGenerated: UserOptions['onGenerated']
onConfigResolved: UserOptions['onConfigResolved']
onOptionsResolved: UserOptions['onOptionsResolved']
onInitialized: UserOptions['onInitialized']
}