-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathindex.d.ts
170 lines (160 loc) · 4.98 KB
/
index.d.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
import type { Plugin, PluginBuild } from 'esbuild';
import type {
BundleOptions,
CustomAtRules,
TransformOptions,
} from 'lightningcss';
declare type EmitDtsConfig = Partial<
Record<'.d.css.ts' | '.css.d.ts' | '*', string>
>;
declare interface BuildOptions
extends Partial<
Pick<
BundleOptions<CustomAtRules>,
| 'targets'
| 'drafts'
| 'nonStandard'
| 'pseudoClasses'
| 'errorRecovery'
| 'visitor'
| 'customAtRules'
>
> {
/**
* force to build css modules files even if `bundle` is disabled in esbuild
* @default false
*/
force?: boolean;
/**
* inline images imported in css as data url even if `bundle` is false
* @default false
*/
forceInlineImages?: boolean;
/**
* emit typescript declaration file for css modules class names
* - `.css.d.ts` : emit `xxx.css.d.ts`
* - `.d.css.ts` : emit `xxx.d.css.ts` (from typescript@5, see https://www.typescriptlang.org/tsconfig#allowArbitraryExtensions)
* - `true` : emit both `xxx.css.d.ts` and `xxx.d.css.ts`
* by default the dts files would be generated in `outdir` of esbuild config, if you want to custom outdir of these dts files:
* ```js
* {
* emitDeclarationFile: {
* '*': 'custom/path/for/all',
* '.css.d.ts': 'custom/path/for/*.css.d.ts',
* '.d.css.ts': 'custom/path/for/*.d.css.ts'
* }
* }
* ```
* @default false
*/
emitDeclarationFile?: boolean | '.d.css.ts' | '.css.d.ts' | EmitDtsConfig;
/**
* set to false to not inject generated css into page;
* @description
* if set to `true`, the generated css will be injected into `head`;
* could be a string of css selector of the element to inject into,
* e.g.
*
* ``` js
* {
* inject: '#some-element-id'
* }
*
* ```
* the plugin will try to get `shadowRoot` of the found element, and append css to the
* `shadowRoot`, if no shadowRoot then append to the found element, if no element found then append to `document.head`.
*
* could be a function with params content & digest (return a string of js code to inject css into page),
* e.g.
*
* ```js
* {
* inject: (content, digest) => `console.log(${content}, ${digest})`
* }
* ```
* @default false
*/
inject?: boolean | string | ((css: string, digest: string) => string);
/**
* Regex to filter certain CSS files.
* @default /\.modules?\.css$/i
*/
filter?: RegExp;
/**
* @see https://lightningcss.dev/css-modules.html#local-css-variables
*/
dashedIndents?: boolean;
/**
* The currently supported segments are:
* [name] - the base name of the CSS file, without the extension
* [hash] - a hash of the full file path
* [local] - the original class name
* @see https://lightningcss.dev/css-modules.html#custom-naming-patterns
*/
pattern?: string;
/**
* localsConvention
* - **cameCase** : `.some-class-name` ==> `someClassName`, the original class name will not to be removed from the locals
* - **camelCaseOnly**: `.some-class-name` ==> `someClassName`, the original class name will be removed from the locals
* - **pascalCase** : `.some-class-name` ==> `SomeClassName`, the original class name will not to be removed from the locals
* - **pascalCaseOnly**: `.some-class-name` ==> `SomeClassName`, the original class name will be removed from the locals
* @default "camelCaseOnly"
*/
localsConvention?:
| 'camelCase'
| 'pascalCase'
| 'camelCaseOnly'
| 'pascalCaseOnly';
/**
* Features that should always be compiled, even when supported by targets.
* @see https://lightningcss.dev/transpilation.html#feature-flags
*/
featuresInclude?: BundleOptions<CustomAtRules>['include'];
/**
* Features that should never be compiled, even when unsupported by targets.
* @see https://lightningcss.dev/transpilation.html#feature-flags
*/
featuresExclude?: BundleOptions<CustomAtRules>['exclude'];
/**
* namedExports
* e.g.:
* ```
* export const someClassName = '.some-class-name__hauajsk';
* ```
* @default false
* Notes:
* - `someClassName` can not be a js key word like `const`, `var` & etc.
* - cannot be used with `inject`
*/
namedExports?: boolean;
/**
* optional package detail
*/
package?: {
name: string;
main?: string;
module?: string;
version: string;
};
}
declare function CssModulesPlugin(options?: BuildOptions): Plugin;
declare namespace CssModulesPlugin {
export type EmitDts = EmitDtsConfig;
export interface Options extends BuildOptions {}
export interface BuildContext {
options: Options;
buildId: string;
buildRoot: string;
packageName: string;
packageVersion: string;
log: (...args: any[]) => void;
relative: (to: string) => string;
normalizedEntries: string[];
}
export declare const setup: (build: PluginBuild, options: Options) => void;
export interface Build extends PluginBuild {
context: BuildContext;
}
export default CssModulesPlugin;
}
export = CssModulesPlugin;