1 | /// <reference types="node" />
|
2 |
|
3 | import { BuildOptions as BuildOptions_2 } from 'esbuild';
|
4 | import { ChangeEvent } from 'rollup';
|
5 | import { CustomPluginOptions } from 'rollup';
|
6 | import * as events from 'events';
|
7 | import * as fs from 'fs';
|
8 | import * as http from 'http';
|
9 | import * as https from 'https';
|
10 | import { IncomingMessage } from 'http';
|
11 | import { InputOptions } from 'rollup';
|
12 | import { LoadResult } from 'rollup';
|
13 | import * as net from 'net';
|
14 | import { OutputBundle } from 'rollup';
|
15 | import { OutputChunk } from 'rollup';
|
16 | import { PartialResolvedId } from 'rollup';
|
17 | import { Plugin as Plugin_2 } from 'rollup';
|
18 | import { PluginContext } from 'rollup';
|
19 | import { PluginHooks } from 'rollup';
|
20 | import * as Postcss from 'postcss';
|
21 | import { RequestOptions } from 'http';
|
22 | import { RequestOptions as RequestOptions_2 } from 'https';
|
23 | import { ResolveIdResult } from 'rollup';
|
24 | import { RollupOptions } from 'rollup';
|
25 | import { RollupOutput } from 'rollup';
|
26 | import { RollupWatcher } from 'rollup';
|
27 | import { Server } from 'http';
|
28 | import { ServerResponse } from 'http';
|
29 | import { SourceDescription } from 'rollup';
|
30 | import { SourceMap } from 'rollup';
|
31 | import * as stream from 'stream';
|
32 | import { TransformOptions as TransformOptions_2 } from 'esbuild';
|
33 | import { TransformPluginContext } from 'rollup';
|
34 | import { TransformResult as TransformResult_2 } from 'rollup';
|
35 | import { TransformResult as TransformResult_3 } from 'esbuild';
|
36 | import * as url from 'url';
|
37 | import { WatcherOptions } from 'rollup';
|
38 |
|
39 | export declare interface Alias {
|
40 | find: string | RegExp
|
41 | replacement: string
|
42 | /**
|
43 | * Instructs the plugin to use an alternative resolving algorithm,
|
44 | * rather than the Rollup's resolver.
|
45 | * @default null
|
46 | */
|
47 | customResolver?: ResolverFunction | ResolverObject | null
|
48 | }
|
49 |
|
50 | /**
|
51 | * Specifies an `Object`, or an `Array` of `Object`,
|
52 | * which defines aliases used to replace values in `import` or `require` statements.
|
53 | * With either format, the order of the entries is important,
|
54 | * in that the first defined rules are applied first.
|
55 | *
|
56 | * This is passed to \@rollup/plugin-alias as the "entries" field
|
57 | * https://github.com/rollup/plugins/tree/master/packages/alias#entries
|
58 | */
|
59 | export declare type AliasOptions = readonly Alias[] | { [find: string]: string }
|
60 |
|
61 | /**
|
62 | * Bundles the app for production.
|
63 | * Returns a Promise containing the build result.
|
64 | */
|
65 | export declare function build(inlineConfig?: InlineConfig): Promise<RollupOutput | RollupOutput[] | RollupWatcher>;
|
66 |
|
67 | export declare interface BuildOptions {
|
68 | /**
|
69 | * Base public path when served in production.
|
70 | * @deprecated `base` is now a root-level config option.
|
71 | */
|
72 | base?: string;
|
73 | /**
|
74 | * Compatibility transform target. The transform is performed with esbuild
|
75 | * and the lowest supported target is es2015/es6. Note this only handles
|
76 | * syntax transformation and does not cover polyfills (except for dynamic
|
77 | * import)
|
78 | *
|
79 | * Default: 'modules' - Similar to `@babel/preset-env`'s targets.esmodules,
|
80 | * transpile targeting browsers that natively support dynamic es module imports.
|
81 | * https://caniuse.com/es6-module-dynamic-import
|
82 | *
|
83 | * Another special value is 'esnext' - which only performs minimal transpiling
|
84 | * (for minification compat) and assumes native dynamic imports support.
|
85 | *
|
86 | * For custom targets, see https://esbuild.github.io/api/#target and
|
87 | * https://esbuild.github.io/content-types/#javascript for more details.
|
88 | */
|
89 | target?: 'modules' | TransformOptions_2['target'] | false;
|
90 | /**
|
91 | * whether to inject dynamic import polyfill.
|
92 | * Note: does not apply to library mode.
|
93 | * @default false
|
94 | */
|
95 | polyfillDynamicImport?: boolean;
|
96 | /**
|
97 | * Directory relative from `root` where build output will be placed. If the
|
98 | * directory exists, it will be removed before the build.
|
99 | * @default 'dist'
|
100 | */
|
101 | outDir?: string;
|
102 | /**
|
103 | * Directory relative from `outDir` where the built js/css/image assets will
|
104 | * be placed.
|
105 | * @default 'assets'
|
106 | */
|
107 | assetsDir?: string;
|
108 | /**
|
109 | * Static asset files smaller than this number (in bytes) will be inlined as
|
110 | * base64 strings. Default limit is `4096` (4kb). Set to `0` to disable.
|
111 | * @default 4096
|
112 | */
|
113 | assetsInlineLimit?: number;
|
114 | /**
|
115 | * Whether to code-split CSS. When enabled, CSS in async chunks will be
|
116 | * inlined as strings in the chunk and inserted via dynamically created
|
117 | * style tags when the chunk is loaded.
|
118 | * @default true
|
119 | */
|
120 | cssCodeSplit?: boolean;
|
121 | /**
|
122 | * If `true`, a separate sourcemap file will be created. If 'inline', the
|
123 | * sourcemap will be appended to the resulting output file as data URI.
|
124 | * 'hidden' works like `true` except that the corresponding sourcemap
|
125 | * comments in the bundled files are suppressed.
|
126 | * @default false
|
127 | */
|
128 | sourcemap?: boolean | 'inline' | 'hidden';
|
129 | /**
|
130 | * Set to `false` to disable minification, or specify the minifier to use.
|
131 | * Available options are 'terser' or 'esbuild'.
|
132 | * @default 'terser'
|
133 | */
|
134 | minify?: boolean | 'terser' | 'esbuild';
|
135 | /**
|
136 | * Options for terser
|
137 | * https://terser.org/docs/api-reference#minify-options
|
138 | */
|
139 | terserOptions?: Terser.MinifyOptions;
|
140 | /**
|
141 | * Options for clean-css
|
142 | * https://github.com/jakubpawlowicz/clean-css#constructor-options
|
143 | */
|
144 | cleanCssOptions?: CleanCSS.Options;
|
145 | /**
|
146 | * Will be merged with internal rollup options.
|
147 | * https://rollupjs.org/guide/en/#big-list-of-options
|
148 | */
|
149 | rollupOptions?: RollupOptions;
|
150 | /**
|
151 | * Options to pass on to `@rollup/plugin-commonjs`
|
152 | */
|
153 | commonjsOptions?: RollupCommonJSOptions;
|
154 | /**
|
155 | * Options to pass on to `@rollup/plugin-dynamic-import-vars`
|
156 | */
|
157 | dynamicImportVarsOptions?: RollupDynamicImportVarsOptions;
|
158 | /**
|
159 | * Whether to write bundle to disk
|
160 | * @default true
|
161 | */
|
162 | write?: boolean;
|
163 | /**
|
164 | * Empty outDir on write.
|
165 | * @default true when outDir is a sub directory of project root
|
166 | */
|
167 | emptyOutDir?: boolean | null;
|
168 | /**
|
169 | * Whether to emit a manifest.json under assets dir to map hash-less filenames
|
170 | * to their hashed versions. Useful when you want to generate your own HTML
|
171 | * instead of using the one generated by Vite.
|
172 | *
|
173 | * Example:
|
174 | *
|
175 | * ```json
|
176 | * {
|
177 | * "main.js": {
|
178 | * "file": "main.68fe3fad.js",
|
179 | * "css": "main.e6b63442.css",
|
180 | * "imports": [...],
|
181 | * "dynamicImports": [...]
|
182 | * }
|
183 | * }
|
184 | * ```
|
185 | * @default false
|
186 | */
|
187 | manifest?: boolean;
|
188 | /**
|
189 | * Build in library mode. The value should be the global name of the lib in
|
190 | * UMD mode. This will produce esm + cjs + umd bundle formats with default
|
191 | * configurations that are suitable for distributing libraries.
|
192 | */
|
193 | lib?: LibraryOptions | false;
|
194 | /**
|
195 | * Produce SSR oriented build. Note this requires specifying SSR entry via
|
196 | * `rollupOptions.input`.
|
197 | */
|
198 | ssr?: boolean | string;
|
199 | /**
|
200 | * Generate SSR manifest for determining style links and asset preload
|
201 | * directives in production.
|
202 | */
|
203 | ssrManifest?: boolean;
|
204 | /**
|
205 | * Set to false to disable brotli compressed size reporting for build.
|
206 | * Can slightly improve build speed.
|
207 | */
|
208 | brotliSize?: boolean;
|
209 | /**
|
210 | * Adjust chunk size warning limit (in kbs).
|
211 | * @default 500
|
212 | */
|
213 | chunkSizeWarningLimit?: number;
|
214 | /**
|
215 | * Rollup watch options
|
216 | * https://rollupjs.org/guide/en/#watchoptions
|
217 | */
|
218 | watch?: WatcherOptions | null;
|
219 | }
|
220 |
|
221 | export declare namespace CleanCSS {
|
222 | /**
|
223 | * Shared options passed when initializing a new instance of CleanCSS that returns either a promise or output
|
224 | */
|
225 | export interface OptionsBase {
|
226 | /**
|
227 | * Controls compatibility mode used; defaults to ie10+ using `'*'`.
|
228 | * Compatibility hash exposes the following properties: `colors`, `properties`, `selectors`, and `units`
|
229 | */
|
230 | compatibility?: '*' | 'ie9' | 'ie8' | 'ie7' | CompatibilityOptions
|
231 |
|
232 | /**
|
233 | * Controls a function for handling remote requests; Defaults to the build in `loadRemoteResource` function
|
234 | */
|
235 | fetch?: (
|
236 | uri: string,
|
237 | inlineRequest: RequestOptions | RequestOptions_2,
|
238 | inlineTimeout: number,
|
239 | done: (message: string | number, body: string) => void
|
240 | ) => void
|
241 |
|
242 | /**
|
243 | * Controls output CSS formatting; defaults to `false`.
|
244 | * Format hash exposes the following properties: `breaks`, `breakWith`, `indentBy`, `indentWith`, `spaces`, and `wrapAt`.
|
245 | */
|
246 | format?: 'beautify' | 'keep-breaks' | FormatOptions | false
|
247 |
|
248 | /**
|
249 | * inline option whitelists which @import rules will be processed. Defaults to `'local'`
|
250 | * Accepts the following values:
|
251 | * 'local': enables local inlining;
|
252 | * 'remote': enables remote inlining;
|
253 | * 'none': disables all inlining;
|
254 | * 'all': enables all inlining, same as ['local', 'remote'];
|
255 | * '[uri]': enables remote inlining from the specified uri;
|
256 | * '![url]': disables remote inlining from the specified uri;
|
257 | */
|
258 | inline?: ReadonlyArray<string> | false
|
259 |
|
260 | /**
|
261 | * Controls extra options for inlining remote @import rules
|
262 | */
|
263 | inlineRequest?: RequestOptions | RequestOptions_2
|
264 |
|
265 | /**
|
266 | * Controls number of milliseconds after which inlining a remote @import fails; defaults to `5000`;
|
267 | */
|
268 | inlineTimeout?: number
|
269 |
|
270 | /**
|
271 | * Controls optimization level used; defaults to `1`.
|
272 | * Level hash exposes `1`, and `2`.
|
273 | */
|
274 | level?: 0 | 1 | 2 | OptimizationsOptions
|
275 |
|
276 | /**
|
277 | * Controls URL rebasing; defaults to `true`;
|
278 | */
|
279 | rebase?: boolean
|
280 |
|
281 | /**
|
282 | * controls a directory to which all URLs are rebased, most likely the directory under which the output file
|
283 | * will live; defaults to the current directory;
|
284 | */
|
285 | rebaseTo?: string
|
286 |
|
287 | /**
|
288 | * Controls whether an output source map is built; defaults to `false`
|
289 | */
|
290 | sourceMap?: boolean
|
291 |
|
292 | /**
|
293 | * Controls embedding sources inside a source map's `sourcesContent` field; defaults to `false`
|
294 | */
|
295 | sourceMapInlineSources?: boolean
|
296 | }
|
297 |
|
298 | /**
|
299 | * Fine grained configuration for compatibility option
|
300 | */
|
301 | export interface CompatibilityOptions {
|
302 | /**
|
303 | * A hash of compatibility options related to color
|
304 | */
|
305 | colors?: {
|
306 | /**
|
307 | * Controls `rgba()` / `hsla()` color support; defaults to `true`
|
308 | */
|
309 | opacity?: boolean
|
310 | }
|
311 | /**
|
312 | * A hash of properties that can be set with compatibility
|
313 | */
|
314 | properties?: {
|
315 | /**
|
316 | * Controls background-clip merging into shorthand; defaults to `true`
|
317 | */
|
318 | backgroundClipMerging?: boolean
|
319 |
|
320 | /**
|
321 | * Controls background-origin merging into shorthand; defaults to `true`
|
322 | */
|
323 | backgroundOriginMerging?: boolean
|
324 |
|
325 | /**
|
326 | * Controls background-size merging into shorthand; defaults to `true`
|
327 | */
|
328 | backgroundSizeMerging?: boolean
|
329 |
|
330 | /**
|
331 | * controls color optimizations; defaults to `true`
|
332 | */
|
333 | colors?: boolean
|
334 |
|
335 | /**
|
336 | * Controls keeping IE bang hack; defaults to `false`
|
337 | */
|
338 | ieBangHack?: boolean
|
339 |
|
340 | /**
|
341 | * Controls keeping IE `filter` / `-ms-filter`; defaults to `false`
|
342 | */
|
343 | ieFilters?: boolean
|
344 |
|
345 | /**
|
346 | * Controls keeping IE prefix hack; defaults to `false`
|
347 | */
|
348 | iePrefixHack?: boolean
|
349 |
|
350 | /**
|
351 | * Controls keeping IE suffix hack; defaults to `false`
|
352 | */
|
353 | ieSuffixHack?: boolean
|
354 |
|
355 | /**
|
356 | * Controls property merging based on understandably; defaults to `true`
|
357 | */
|
358 | merging?: boolean
|
359 |
|
360 | /**
|
361 | * Controls shortening pixel units into `pc`, `pt`, or `in` units; defaults to `false`
|
362 | */
|
363 | shorterLengthUnits?: false
|
364 |
|
365 | /**
|
366 | * Controls keeping space after closing brace - `url() no-repeat` into `url()no-repeat`; defaults to `true`
|
367 | */
|
368 | spaceAfterClosingBrace?: true
|
369 |
|
370 | /**
|
371 | * Controls keeping quoting inside `url()`; defaults to `false`
|
372 | */
|
373 | urlQuotes?: boolean
|
374 |
|
375 | /**
|
376 | * Controls removal of units `0` value; defaults to `true`
|
377 | */
|
378 | zeroUnits?: boolean
|
379 | }
|
380 | /**
|
381 | * A hash of options related to compatibility of selectors
|
382 | */
|
383 | selectors?: {
|
384 | /**
|
385 | * Controls extra space before `nav` element; defaults to `false`
|
386 | */
|
387 | adjacentSpace?: boolean
|
388 |
|
389 | /**
|
390 | * Controls removal of IE7 selector hacks, e.g. `*+html...`; defaults to `true`
|
391 | */
|
392 | ie7Hack?: boolean
|
393 |
|
394 | /**
|
395 | * Controls a whitelist of mergeable pseudo classes; defaults to `[':active', ...]`
|
396 | */
|
397 | mergeablePseudoClasses?: ReadonlyArray<string>
|
398 |
|
399 | /**
|
400 | * Controls a whitelist of mergeable pseudo elements; defaults to `['::after', ...]`
|
401 | */
|
402 | mergeablePseudoElements: ReadonlyArray<string>
|
403 |
|
404 | /**
|
405 | * Controls maximum number of selectors in a single rule (since 4.1.0); defaults to `8191`
|
406 | */
|
407 | mergeLimit: number
|
408 |
|
409 | /**
|
410 | * Controls merging of rules with multiple pseudo classes / elements (since 4.1.0); defaults to `true`
|
411 | */
|
412 | multiplePseudoMerging: boolean
|
413 | }
|
414 | /**
|
415 | * A hash of options related to comparability of supported units
|
416 | */
|
417 | units?: {
|
418 | /**
|
419 | * Controls treating `ch` as a supported unit; defaults to `true`
|
420 | */
|
421 | ch?: boolean
|
422 |
|
423 | /**
|
424 | * Controls treating `in` as a supported unit; defaults to `true`
|
425 | */
|
426 | in?: boolean
|
427 |
|
428 | /**
|
429 | * Controls treating `pc` as a supported unit; defaults to `true`
|
430 | */
|
431 | pc?: boolean
|
432 |
|
433 | /**
|
434 | * Controls treating `pt` as a supported unit; defaults to `true`
|
435 | */
|
436 | pt?: boolean
|
437 |
|
438 | /**
|
439 | * Controls treating `rem` as a supported unit; defaults to `true`
|
440 | */
|
441 | rem?: boolean
|
442 |
|
443 | /**
|
444 | * Controls treating `vh` as a supported unit; defaults to `true`
|
445 | */
|
446 | vh?: boolean
|
447 |
|
448 | /**
|
449 | * Controls treating `vm` as a supported unit; defaults to `true`
|
450 | */
|
451 | vm?: boolean
|
452 |
|
453 | /**
|
454 | * Controls treating `vmax` as a supported unit; defaults to `true`
|
455 | */
|
456 | vmax?: boolean
|
457 |
|
458 | /**
|
459 | * Controls treating `vmin` as a supported unit; defaults to `true`
|
460 | */
|
461 | vmin?: boolean
|
462 | }
|
463 | }
|
464 |
|
465 | /**
|
466 | * Fine grained options for configuring the CSS formatting
|
467 | */
|
468 | export interface FormatOptions {
|
469 | /**
|
470 | * Controls where to insert breaks
|
471 | */
|
472 | breaks?: {
|
473 | /**
|
474 | * Controls if a line break comes after an at-rule; e.g. `@charset`; defaults to `false`
|
475 | */
|
476 | afterAtRule?: boolean
|
477 |
|
478 | /**
|
479 | * Controls if a line break comes after a block begins; e.g. `@media`; defaults to `false`
|
480 | */
|
481 | afterBlockBegins?: boolean
|
482 |
|
483 | /**
|
484 | * Controls if a line break comes after a block ends, defaults to `false`
|
485 | */
|
486 | afterBlockEnds?: boolean
|
487 |
|
488 | /**
|
489 | * Controls if a line break comes after a comment; defaults to `false`
|
490 | */
|
491 | afterComment?: boolean
|
492 |
|
493 | /**
|
494 | * Controls if a line break comes after a property; defaults to `false`
|
495 | */
|
496 | afterProperty?: boolean
|
497 |
|
498 | /**
|
499 | * Controls if a line break comes after a rule begins; defaults to `false`
|
500 | */
|
501 | afterRuleBegins?: boolean
|
502 |
|
503 | /**
|
504 | * Controls if a line break comes after a rule ends; defaults to `false`
|
505 | */
|
506 | afterRuleEnds?: boolean
|
507 |
|
508 | /**
|
509 | * Controls if a line break comes before a block ends; defaults to `false`
|
510 | */
|
511 | beforeBlockEnds?: boolean
|
512 |
|
513 | /**
|
514 | * Controls if a line break comes between selectors; defaults to `false`
|
515 | */
|
516 | betweenSelectors?: boolean
|
517 | }
|
518 | /**
|
519 | * Controls the new line character, can be `'\r\n'` or `'\n'`(aliased as `'windows'` and `'unix'`
|
520 | * or `'crlf'` and `'lf'`); defaults to system one, so former on Windows and latter on Unix
|
521 | */
|
522 | breakWith?: string
|
523 |
|
524 | /**
|
525 | * Controls number of characters to indent with; defaults to `0`
|
526 | */
|
527 | indentBy?: number
|
528 |
|
529 | /**
|
530 | * Controls a character to indent with, can be `'space'` or `'tab'`; defaults to `'space'`
|
531 | */
|
532 | indentWith?: 'space' | 'tab'
|
533 |
|
534 | /**
|
535 | * Controls where to insert spaces
|
536 | */
|
537 | spaces?: {
|
538 | /**
|
539 | * Controls if spaces come around selector relations; e.g. `div > a`; defaults to `false`
|
540 | */
|
541 | aroundSelectorRelation?: boolean
|
542 |
|
543 | /**
|
544 | * Controls if a space comes before a block begins; e.g. `.block {`; defaults to `false`
|
545 | */
|
546 | beforeBlockBegins?: boolean
|
547 |
|
548 | /**
|
549 | * Controls if a space comes before a value; e.g. `width: 1rem`; defaults to `false`
|
550 | */
|
551 | beforeValue?: boolean
|
552 | }
|
553 | /**
|
554 | * Controls maximum line length; defaults to `false`
|
555 | */
|
556 | wrapAt?: false | number
|
557 |
|
558 | /**
|
559 | * Controls removing trailing semicolons in rule; defaults to `false` - means remove
|
560 | */
|
561 | semicolonAfterLastProperty?: boolean
|
562 | }
|
563 |
|
564 | /**
|
565 | * Fine grained options for configuring optimizations
|
566 | */
|
567 | export interface OptimizationsOptions {
|
568 | 1?: {
|
569 | /**
|
570 | * Sets all optimizations at this level unless otherwise specified
|
571 | */
|
572 | all?: boolean
|
573 |
|
574 | /**
|
575 | * Controls `@charset` moving to the front of a stylesheet; defaults to `true`
|
576 | */
|
577 | cleanupCharsets?: boolean
|
578 |
|
579 | /**
|
580 | * Controls URL normalization; defaults to `true`
|
581 | */
|
582 | normalizeUrls?: boolean
|
583 |
|
584 | /**
|
585 | * Controls `background` property optimizations; defaults to `true`
|
586 | */
|
587 | optimizeBackground?: boolean
|
588 |
|
589 | /**
|
590 | * Controls `border-radius` property optimizations; defaults to `true`
|
591 | */
|
592 | optimizeBorderRadius?: boolean
|
593 |
|
594 | /**
|
595 | * Controls `filter` property optimizations; defaults to `true`
|
596 | */
|
597 | optimizeFilter?: boolean
|
598 |
|
599 | /**
|
600 | * Controls `font` property optimizations; defaults to `true`
|
601 | */
|
602 | optimizeFont?: boolean
|
603 |
|
604 | /**
|
605 | * Controls `font-weight` property optimizations; defaults to `true`
|
606 | */
|
607 | optimizeFontWeight?: boolean
|
608 |
|
609 | /**
|
610 | * Controls `outline` property optimizations; defaults to `true`
|
611 | */
|
612 | optimizeOutline?: boolean
|
613 |
|
614 | /**
|
615 | * Controls removing empty rules and nested blocks; defaults to `true`
|
616 | */
|
617 | removeEmpty?: boolean
|
618 |
|
619 | /**
|
620 | * Controls removing negative paddings; defaults to `true`
|
621 | */
|
622 | removeNegativePaddings?: boolean
|
623 |
|
624 | /**
|
625 | * Controls removing quotes when unnecessary; defaults to `true`
|
626 | */
|
627 | removeQuotes?: boolean
|
628 |
|
629 | /**
|
630 | * Controls removing unused whitespace; defaults to `true`
|
631 | */
|
632 | removeWhitespace?: boolean
|
633 |
|
634 | /**
|
635 | * Contols removing redundant zeros; defaults to `true`
|
636 | */
|
637 | replaceMultipleZeros?: boolean
|
638 |
|
639 | /**
|
640 | * Controls replacing time units with shorter values; defaults to `true`
|
641 | */
|
642 | replaceTimeUnits?: boolean
|
643 |
|
644 | /**
|
645 | * Controls replacing zero values with units; defaults to `true`
|
646 | */
|
647 | replaceZeroUnits?: boolean
|
648 |
|
649 | /**
|
650 | * Rounds pixel values to `N` decimal places; `false` disables rounding; defaults to `false`
|
651 | */
|
652 | roundingPrecision?: boolean
|
653 |
|
654 | /**
|
655 | * denotes selector sorting method; can be `'natural'` or `'standard'`, `'none'`, or false (the last two
|
656 | * since 4.1.0); defaults to `'standard'`
|
657 | */
|
658 | selectorsSortingMethod?: 'standard' | 'natural' | 'none'
|
659 |
|
660 | /**
|
661 | * denotes a number of /*! ... * / comments preserved; defaults to `all`
|
662 | */
|
663 | specialComments?: 'all' | '1' | 1 | '0' | 0
|
664 |
|
665 | /**
|
666 | * Controls at-rules (e.g. `@charset`, `@import`) optimizing; defaults to `true`
|
667 | */
|
668 | tidyAtRules?: boolean
|
669 |
|
670 | /**
|
671 | * Controls block scopes (e.g. `@media`) optimizing; defaults to `true`
|
672 | */
|
673 | tidyBlockScopes?: boolean
|
674 |
|
675 | /**
|
676 | * Controls selectors optimizing; defaults to `true`
|
677 | */
|
678 | tidySelectors?: boolean
|
679 |
|
680 | /**
|
681 | * Defines a callback for fine-grained property optimization; defaults to no-op
|
682 | */
|
683 | transform?: (
|
684 | propertyName: string,
|
685 | propertyValue: string,
|
686 | selector?: string
|
687 | ) => string
|
688 | }
|
689 | 2?: {
|
690 | /**
|
691 | * Sets all optimizations at this level unless otherwise specified
|
692 | */
|
693 | all?: boolean
|
694 |
|
695 | /**
|
696 | * Controls adjacent rules merging; defaults to true
|
697 | */
|
698 | mergeAdjacentRules?: boolean
|
699 |
|
700 | /**
|
701 | * Controls merging properties into shorthands; defaults to true
|
702 | */
|
703 | mergeIntoShorthands?: boolean
|
704 |
|
705 | /**
|
706 | * Controls `@media` merging; defaults to true
|
707 | */
|
708 | mergeMedia?: boolean
|
709 |
|
710 | /**
|
711 | * Controls non-adjacent rule merging; defaults to true
|
712 | */
|
713 | mergeNonAdjacentRules?: boolean
|
714 |
|
715 | /**
|
716 | * Controls semantic merging; defaults to false
|
717 | */
|
718 | mergeSemantically?: boolean
|
719 |
|
720 | /**
|
721 | * Controls property overriding based on understandably; defaults to true
|
722 | */
|
723 | overrideProperties?: boolean
|
724 |
|
725 | /**
|
726 | * Controls removing empty rules and nested blocks; defaults to `true`
|
727 | */
|
728 | removeEmpty?: boolean
|
729 |
|
730 | /**
|
731 | * Controls non-adjacent rule reducing; defaults to true
|
732 | */
|
733 | reduceNonAdjacentRules?: boolean
|
734 |
|
735 | /**
|
736 | * Controls duplicate `@font-face` removing; defaults to true
|
737 | */
|
738 | removeDuplicateFontRules?: boolean
|
739 |
|
740 | /**
|
741 | * Controls duplicate `@media` removing; defaults to true
|
742 | */
|
743 | removeDuplicateMediaBlocks?: boolean
|
744 |
|
745 | /**
|
746 | * Controls duplicate rules removing; defaults to true
|
747 | */
|
748 | removeDuplicateRules?: boolean
|
749 |
|
750 | /**
|
751 | * Controls unused at rule removing; defaults to false (available since 4.1.0)
|
752 | */
|
753 | removeUnusedAtRules?: boolean
|
754 |
|
755 | /**
|
756 | * Controls rule restructuring; defaults to false
|
757 | */
|
758 | restructureRules?: boolean
|
759 |
|
760 | /**
|
761 | * Controls which properties won't be optimized, defaults to `[]` which means all will be optimized (since 4.1.0)
|
762 | */
|
763 | skipProperties?: ReadonlyArray<string>
|
764 | }
|
765 | }
|
766 |
|
767 | /**
|
768 | * Options when returning a promise
|
769 | */
|
770 | export type OptionsPromise = OptionsBase & {
|
771 | /**
|
772 | * If you prefer clean-css to return a Promise object then you need to explicitly ask for it; defaults to `false`
|
773 | */
|
774 | returnPromise: true
|
775 | }
|
776 |
|
777 | /**
|
778 | * Options when returning an output
|
779 | */
|
780 | export type OptionsOutput = OptionsBase & {
|
781 | /**
|
782 | * If you prefer clean-css to return a Promise object then you need to explicitly ask for it; defaults to `false`
|
783 | */
|
784 | returnPromise?: false
|
785 | }
|
786 |
|
787 | /**
|
788 | * Discriminant union of both sets of options types. If you initialize without setting `returnPromise: true`
|
789 | * and want to return a promise, you will need to cast to the correct options type so that TypeScript
|
790 | * knows what the expected return type will be:
|
791 | * `(options = options as CleanCSS.OptionsPromise).returnPromise = true`
|
792 | */
|
793 | export type Options = OptionsPromise | OptionsOutput
|
794 | }
|
795 |
|
796 | export declare interface ConfigEnv {
|
797 | command: 'build' | 'serve';
|
798 | mode: string;
|
799 | }
|
800 |
|
801 | export declare namespace Connect {
|
802 | export type ServerHandle = HandleFunction | http.Server
|
803 |
|
804 | export class IncomingMessage extends http.IncomingMessage {
|
805 | originalUrl?: http.IncomingMessage['url']
|
806 | }
|
807 |
|
808 | export type NextFunction = (err?: any) => void
|
809 |
|
810 | export type SimpleHandleFunction = (
|
811 | req: IncomingMessage,
|
812 | res: http.ServerResponse
|
813 | ) => void
|
814 | export type NextHandleFunction = (
|
815 | req: IncomingMessage,
|
816 | res: http.ServerResponse,
|
817 | next: NextFunction
|
818 | ) => void
|
819 | export type ErrorHandleFunction = (
|
820 | err: any,
|
821 | req: IncomingMessage,
|
822 | res: http.ServerResponse,
|
823 | next: NextFunction
|
824 | ) => void
|
825 | export type HandleFunction =
|
826 | | SimpleHandleFunction
|
827 | | NextHandleFunction
|
828 | | ErrorHandleFunction
|
829 |
|
830 | export interface ServerStackItem {
|
831 | route: string
|
832 | handle: ServerHandle
|
833 | }
|
834 |
|
835 | export interface Server extends NodeJS.EventEmitter {
|
836 | (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void
|
837 |
|
838 | route: string
|
839 | stack: ServerStackItem[]
|
840 |
|
841 | /**
|
842 | * Utilize the given middleware `handle` to the given `route`,
|
843 | * defaulting to _/_. This "route" is the mount-point for the
|
844 | * middleware, when given a value other than _/_ the middleware
|
845 | * is only effective when that segment is present in the request's
|
846 | * pathname.
|
847 | *
|
848 | * For example if we were to mount a function at _/admin_, it would
|
849 | * be invoked on _/admin_, and _/admin/settings_, however it would
|
850 | * not be invoked for _/_, or _/posts_.
|
851 | */
|
852 | use(fn: NextHandleFunction): Server
|
853 | use(fn: HandleFunction): Server
|
854 | use(route: string, fn: NextHandleFunction): Server
|
855 | use(route: string, fn: HandleFunction): Server
|
856 |
|
857 | /**
|
858 | * Handle server requests, punting them down
|
859 | * the middleware stack.
|
860 | */
|
861 | handle(
|
862 | req: http.IncomingMessage,
|
863 | res: http.ServerResponse,
|
864 | next: Function
|
865 | ): void
|
866 |
|
867 | /**
|
868 | * Listen for connections.
|
869 | *
|
870 | * This method takes the same arguments
|
871 | * as node's `http.Server#listen()`.
|
872 | *
|
873 | * HTTP and HTTPS:
|
874 | *
|
875 | * If you run your application both as HTTP
|
876 | * and HTTPS you may wrap them individually,
|
877 | * since your Connect "server" is really just
|
878 | * a JavaScript `Function`.
|
879 | *
|
880 | * var connect = require('connect')
|
881 | * , http = require('http')
|
882 | * , https = require('https');
|
883 | *
|
884 | * var app = connect();
|
885 | *
|
886 | * http.createServer(app).listen(80);
|
887 | * https.createServer(options, app).listen(443);
|
888 | */
|
889 | listen(
|
890 | port: number,
|
891 | hostname?: string,
|
892 | backlog?: number,
|
893 | callback?: Function
|
894 | ): http.Server
|
895 | listen(port: number, hostname?: string, callback?: Function): http.Server
|
896 | listen(path: string, callback?: Function): http.Server
|
897 | listen(handle: any, listeningListener?: Function): http.Server
|
898 | }
|
899 | }
|
900 |
|
901 | export declare interface ConnectedPayload {
|
902 | type: 'connected'
|
903 | }
|
904 |
|
905 | /**
|
906 | * https://github.com/expressjs/cors#configuration-options
|
907 | */
|
908 | export declare interface CorsOptions {
|
909 | origin?: CorsOrigin | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void);
|
910 | methods?: string | string[];
|
911 | allowedHeaders?: string | string[];
|
912 | exposedHeaders?: string | string[];
|
913 | credentials?: boolean;
|
914 | maxAge?: number;
|
915 | preflightContinue?: boolean;
|
916 | optionsSuccessStatus?: number;
|
917 | }
|
918 |
|
919 | export declare type CorsOrigin = boolean | string | RegExp | (string | RegExp)[];
|
920 |
|
921 | export declare function createLogger(level?: LogLevel, options?: LoggerOptions): Logger;
|
922 |
|
923 | export declare function createServer(inlineConfig?: InlineConfig): Promise<ViteDevServer>;
|
924 |
|
925 | export declare interface CSSModulesOptions {
|
926 | getJSON?: (cssFileName: string, json: Record<string, string>, outputFileName: string) => void;
|
927 | scopeBehaviour?: 'global' | 'local';
|
928 | globalModulePaths?: RegExp[];
|
929 | generateScopedName?: string | ((name: string, filename: string, css: string) => string);
|
930 | hashPrefix?: string;
|
931 | /**
|
932 | * default: null
|
933 | */
|
934 | localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly' | null;
|
935 | }
|
936 |
|
937 | export declare interface CSSOptions {
|
938 | /**
|
939 | * https://github.com/css-modules/postcss-modules
|
940 | */
|
941 | modules?: CSSModulesOptions | false;
|
942 | preprocessorOptions?: Record<string, any>;
|
943 | postcss?: string | (Postcss.ProcessOptions & {
|
944 | plugins?: Postcss.Plugin[];
|
945 | });
|
946 | }
|
947 |
|
948 | export declare interface CustomPayload {
|
949 | type: 'custom'
|
950 | event: string
|
951 | data?: any
|
952 | }
|
953 |
|
954 | /**
|
955 | * Type helper to make it easier to use vite.config.ts
|
956 | * accepts a direct {@link UserConfig} object, or a function that returns it.
|
957 | * The function receives a {@link ConfigEnv} object that exposes two properties:
|
958 | * `command` (either `'build'` or `'serve'`), and `mode`.
|
959 | */
|
960 | export declare function defineConfig(config: UserConfigExport): UserConfigExport;
|
961 |
|
962 | export declare interface DepOptimizationMetadata {
|
963 | /**
|
964 | * The main hash is determined by user config and dependency lockfiles.
|
965 | * This is checked on server startup to avoid unnecessary re-bundles.
|
966 | */
|
967 | hash: string;
|
968 | /**
|
969 | * The browser hash is determined by the main hash plus additional dependencies
|
970 | * discovered at runtime. This is used to invalidate browser requests to
|
971 | * optimized deps.
|
972 | */
|
973 | browserHash: string;
|
974 | optimized: Record<string, {
|
975 | file: string;
|
976 | src: string;
|
977 | needsInterop: boolean;
|
978 | }>;
|
979 | }
|
980 |
|
981 | export declare interface DepOptimizationOptions {
|
982 | /**
|
983 | * By default, Vite will crawl your index.html to detect dependencies that
|
984 | * need to be pre-bundled. If build.rollupOptions.input is specified, Vite
|
985 | * will crawl those entry points instead.
|
986 | *
|
987 | * If neither of these fit your needs, you can specify custom entries using
|
988 | * this option - the value should be a fast-glob pattern or array of patterns
|
989 | * (https://github.com/mrmlnc/fast-glob#basic-syntax) that are relative from
|
990 | * vite project root. This will overwrite default entries inference.
|
991 | */
|
992 | entries?: string | string[];
|
993 | /**
|
994 | * Force optimize listed dependencies (must be resolvable import paths,
|
995 | * cannot be globs).
|
996 | */
|
997 | include?: string[];
|
998 | /**
|
999 | * Do not optimize these dependencies (must be resolvable import paths,
|
1000 | * cannot be globs).
|
1001 | */
|
1002 | exclude?: string[];
|
1003 | /**
|
1004 | * Options to pass to esbuild during the dep scanning and optimization
|
1005 | *
|
1006 | * Certain options are omitted since changing them would not be compatible
|
1007 | * with Vite's dep optimization.
|
1008 | *
|
1009 | * - `external` is also omitted, use Vite's `optimizeDeps.exclude` option
|
1010 | * - `plugins` are merged with Vite's dep plugin
|
1011 | * - `keepNames` takes precedence over the deprecated `optimizeDeps.keepNames`
|
1012 | *
|
1013 | * https://esbuild.github.io/api
|
1014 | */
|
1015 | esbuildOptions?: Omit<BuildOptions_2, 'bundle' | 'entryPoints' | 'external' | 'write' | 'watch' | 'outdir' | 'outfile' | 'outbase' | 'outExtension' | 'metafile'>;
|
1016 | /**
|
1017 | * @deprecated use `esbuildOptions.keepNames`
|
1018 | */
|
1019 | keepNames?: boolean;
|
1020 | }
|
1021 |
|
1022 | export declare interface ErrorPayload {
|
1023 | type: 'error'
|
1024 | err: {
|
1025 | [name: string]: any
|
1026 | message: string
|
1027 | stack: string
|
1028 | id?: string
|
1029 | frame?: string
|
1030 | plugin?: string
|
1031 | pluginCode?: string
|
1032 | loc?: {
|
1033 | file?: string
|
1034 | line: number
|
1035 | column: number
|
1036 | }
|
1037 | }
|
1038 | }
|
1039 |
|
1040 | export declare interface ESBuildOptions extends TransformOptions_2 {
|
1041 | include?: string | RegExp | string[] | RegExp[];
|
1042 | exclude?: string | RegExp | string[] | RegExp[];
|
1043 | jsxInject?: string;
|
1044 | }
|
1045 |
|
1046 | export declare type ESBuildTransformResult = Omit<TransformResult_3, 'map'> & {
|
1047 | map: SourceMap;
|
1048 | };
|
1049 |
|
1050 | export declare interface FileSystemServeOptions {
|
1051 | /**
|
1052 | * Strictly restrict file accessing outside of allowing paths.
|
1053 | *
|
1054 | * Set to `false` to disable the warning
|
1055 | * Default to false at this moment, will enabled by default in the future versions.
|
1056 | *
|
1057 | * @expiremental
|
1058 | * @default undefined
|
1059 | */
|
1060 | strict?: boolean | undefined;
|
1061 | /**
|
1062 | * Restrict accessing files outside the allowed directories.
|
1063 | *
|
1064 | * Accepts absolute path or a path relative to project root.
|
1065 | * Will try to search up for workspace root by default.
|
1066 | *
|
1067 | * @expiremental
|
1068 | */
|
1069 | allow?: string[];
|
1070 | }
|
1071 |
|
1072 | export declare interface FSWatcher extends fs.FSWatcher {
|
1073 | options: WatchOptions
|
1074 |
|
1075 | /**
|
1076 | * Constructs a new FSWatcher instance with optional WatchOptions parameter.
|
1077 | */
|
1078 | (options?: WatchOptions): void
|
1079 |
|
1080 | /**
|
1081 | * Add files, directories, or glob patterns for tracking. Takes an array of strings or just one
|
1082 | * string.
|
1083 | */
|
1084 | add(paths: string | ReadonlyArray<string>): void
|
1085 |
|
1086 | /**
|
1087 | * Stop watching files, directories, or glob patterns. Takes an array of strings or just one
|
1088 | * string.
|
1089 | */
|
1090 | unwatch(paths: string | ReadonlyArray<string>): void
|
1091 |
|
1092 | /**
|
1093 | * Returns an object representing all the paths on the file system being watched by this
|
1094 | * `FSWatcher` instance. The object's keys are all the directories (using absolute paths unless
|
1095 | * the `cwd` option was used), and the values are arrays of the names of the items contained in
|
1096 | * each directory.
|
1097 | */
|
1098 | getWatched(): {
|
1099 | [directory: string]: string[]
|
1100 | }
|
1101 |
|
1102 | /**
|
1103 | * Removes all listeners from watched files.
|
1104 | */
|
1105 | close(): Promise<void>
|
1106 |
|
1107 | on(
|
1108 | event: 'add' | 'addDir' | 'change',
|
1109 | listener: (path: string, stats?: fs.Stats) => void
|
1110 | ): this
|
1111 |
|
1112 | on(
|
1113 | event: 'all',
|
1114 | listener: (
|
1115 | eventName: 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir',
|
1116 | path: string,
|
1117 | stats?: fs.Stats
|
1118 | ) => void
|
1119 | ): this
|
1120 |
|
1121 | /**
|
1122 | * Error occurred
|
1123 | */
|
1124 | on(event: 'error', listener: (error: Error) => void): this
|
1125 |
|
1126 | /**
|
1127 | * Exposes the native Node `fs.FSWatcher events`
|
1128 | */
|
1129 | on(
|
1130 | event: 'raw',
|
1131 | listener: (eventName: string, path: string, details: any) => void
|
1132 | ): this
|
1133 |
|
1134 | /**
|
1135 | * Fires when the initial scan is complete
|
1136 | */
|
1137 | on(event: 'ready', listener: () => void): this
|
1138 |
|
1139 | on(event: 'unlink' | 'unlinkDir', listener: (path: string) => void): this
|
1140 |
|
1141 | on(event: string, listener: (...args: any[]) => void): this
|
1142 | }
|
1143 |
|
1144 | export declare interface FullReloadPayload {
|
1145 | type: 'full-reload'
|
1146 | path?: string
|
1147 | }
|
1148 |
|
1149 | export declare interface HmrContext {
|
1150 | file: string;
|
1151 | timestamp: number;
|
1152 | modules: Array<ModuleNode>;
|
1153 | read: () => string | Promise<string>;
|
1154 | server: ViteDevServer;
|
1155 | }
|
1156 |
|
1157 | export declare interface HmrOptions {
|
1158 | protocol?: string;
|
1159 | host?: string;
|
1160 | port?: number;
|
1161 | clientPort?: number;
|
1162 | path?: string;
|
1163 | timeout?: number;
|
1164 | overlay?: boolean;
|
1165 | server?: Server;
|
1166 | }
|
1167 |
|
1168 | export declare type HMRPayload =
|
1169 | | ConnectedPayload
|
1170 | | UpdatePayload
|
1171 | | FullReloadPayload
|
1172 | | CustomPayload
|
1173 | | ErrorPayload
|
1174 | | PrunePayload
|
1175 |
|
1176 | export declare interface HtmlTagDescriptor {
|
1177 | tag: string;
|
1178 | attrs?: Record<string, string | boolean | undefined>;
|
1179 | children?: string | HtmlTagDescriptor[];
|
1180 | /**
|
1181 | * default: 'head-prepend'
|
1182 | */
|
1183 | injectTo?: 'head' | 'body' | 'head-prepend' | 'body-prepend';
|
1184 | }
|
1185 |
|
1186 | export declare namespace HttpProxy {
|
1187 | export type ProxyTarget = ProxyTargetUrl | ProxyTargetDetailed
|
1188 |
|
1189 | export type ProxyTargetUrl = string | Partial<url.Url>
|
1190 |
|
1191 | export interface ProxyTargetDetailed {
|
1192 | host: string
|
1193 | port: number
|
1194 | protocol?: string
|
1195 | hostname?: string
|
1196 | socketPath?: string
|
1197 | key?: string
|
1198 | passphrase?: string
|
1199 | pfx?: Buffer | string
|
1200 | cert?: string
|
1201 | ca?: string
|
1202 | ciphers?: string
|
1203 | secureProtocol?: string
|
1204 | }
|
1205 |
|
1206 | export type ErrorCallback = (
|
1207 | err: Error,
|
1208 | req: http.IncomingMessage,
|
1209 | res: http.ServerResponse,
|
1210 | target?: ProxyTargetUrl
|
1211 | ) => void
|
1212 |
|
1213 | export class Server extends events.EventEmitter {
|
1214 | /**
|
1215 | * Creates the proxy server with specified options.
|
1216 | * @param options - Config object passed to the proxy
|
1217 | */
|
1218 | constructor(options?: ServerOptions)
|
1219 |
|
1220 | /**
|
1221 | * Used for proxying regular HTTP(S) requests
|
1222 | * @param req - Client request.
|
1223 | * @param res - Client response.
|
1224 | * @param options - Additionnal options.
|
1225 | */
|
1226 | web(
|
1227 | req: http.IncomingMessage,
|
1228 | res: http.ServerResponse,
|
1229 | options?: ServerOptions,
|
1230 | callback?: ErrorCallback
|
1231 | ): void
|
1232 |
|
1233 | /**
|
1234 | * Used for proxying regular HTTP(S) requests
|
1235 | * @param req - Client request.
|
1236 | * @param socket - Client socket.
|
1237 | * @param head - Client head.
|
1238 | * @param options - Additionnal options.
|
1239 | */
|
1240 | ws(
|
1241 | req: http.IncomingMessage,
|
1242 | socket: any,
|
1243 | head: any,
|
1244 | options?: ServerOptions,
|
1245 | callback?: ErrorCallback
|
1246 | ): void
|
1247 |
|
1248 | /**
|
1249 | * A function that wraps the object in a webserver, for your convenience
|
1250 | * @param port - Port to listen on
|
1251 | */
|
1252 | listen(port: number): Server
|
1253 |
|
1254 | /**
|
1255 | * A function that closes the inner webserver and stops listening on given port
|
1256 | */
|
1257 | close(callback?: () => void): void
|
1258 |
|
1259 | /**
|
1260 | * Creates the proxy server with specified options.
|
1261 | * @param options - Config object passed to the proxy
|
1262 | * @returns Proxy object with handlers for `ws` and `web` requests
|
1263 | */
|
1264 | static createProxyServer(options?: ServerOptions): Server
|
1265 |
|
1266 | /**
|
1267 | * Creates the proxy server with specified options.
|
1268 | * @param options - Config object passed to the proxy
|
1269 | * @returns Proxy object with handlers for `ws` and `web` requests
|
1270 | */
|
1271 | static createServer(options?: ServerOptions): Server
|
1272 |
|
1273 | /**
|
1274 | * Creates the proxy server with specified options.
|
1275 | * @param options - Config object passed to the proxy
|
1276 | * @returns Proxy object with handlers for `ws` and `web` requests
|
1277 | */
|
1278 | static createProxy(options?: ServerOptions): Server
|
1279 |
|
1280 | addListener(event: string, listener: () => void): this
|
1281 | on(event: string, listener: () => void): this
|
1282 | on(event: 'error', listener: ErrorCallback): this
|
1283 | on(
|
1284 | event: 'start',
|
1285 | listener: (
|
1286 | req: http.IncomingMessage,
|
1287 | res: http.ServerResponse,
|
1288 | target: ProxyTargetUrl
|
1289 | ) => void
|
1290 | ): this
|
1291 | on(
|
1292 | event: 'proxyReq',
|
1293 | listener: (
|
1294 | proxyReq: http.ClientRequest,
|
1295 | req: http.IncomingMessage,
|
1296 | res: http.ServerResponse,
|
1297 | options: ServerOptions
|
1298 | ) => void
|
1299 | ): this
|
1300 | on(
|
1301 | event: 'proxyRes',
|
1302 | listener: (
|
1303 | proxyRes: http.IncomingMessage,
|
1304 | req: http.IncomingMessage,
|
1305 | res: http.ServerResponse
|
1306 | ) => void
|
1307 | ): this
|
1308 | on(
|
1309 | event: 'proxyReqWs',
|
1310 | listener: (
|
1311 | proxyReq: http.ClientRequest,
|
1312 | req: http.IncomingMessage,
|
1313 | socket: net.Socket,
|
1314 | options: ServerOptions,
|
1315 | head: any
|
1316 | ) => void
|
1317 | ): this
|
1318 | on(
|
1319 | event: 'econnreset',
|
1320 | listener: (
|
1321 | err: Error,
|
1322 | req: http.IncomingMessage,
|
1323 | res: http.ServerResponse,
|
1324 | target: ProxyTargetUrl
|
1325 | ) => void
|
1326 | ): this
|
1327 | on(
|
1328 | event: 'end',
|
1329 | listener: (
|
1330 | req: http.IncomingMessage,
|
1331 | res: http.ServerResponse,
|
1332 | proxyRes: http.IncomingMessage
|
1333 | ) => void
|
1334 | ): this
|
1335 | on(
|
1336 | event: 'close',
|
1337 | listener: (
|
1338 | proxyRes: http.IncomingMessage,
|
1339 | proxySocket: net.Socket,
|
1340 | proxyHead: any
|
1341 | ) => void
|
1342 | ): this
|
1343 |
|
1344 | once(event: string, listener: () => void): this
|
1345 | removeListener(event: string, listener: () => void): this
|
1346 | removeAllListeners(event?: string): this
|
1347 | getMaxListeners(): number
|
1348 | setMaxListeners(n: number): this
|
1349 | listeners(event: string): Array<() => void>
|
1350 | emit(event: string, ...args: any[]): boolean
|
1351 | listenerCount(type: string): number
|
1352 | }
|
1353 |
|
1354 | export interface ServerOptions {
|
1355 | /** URL string to be parsed with the url module. */
|
1356 | target?: ProxyTarget
|
1357 | /** URL string to be parsed with the url module. */
|
1358 | forward?: ProxyTargetUrl
|
1359 | /** Object to be passed to http(s).request. */
|
1360 | agent?: any
|
1361 | /** Object to be passed to https.createServer(). */
|
1362 | ssl?: any
|
1363 | /** If you want to proxy websockets. */
|
1364 | ws?: boolean
|
1365 | /** Adds x- forward headers. */
|
1366 | xfwd?: boolean
|
1367 | /** Verify SSL certificate. */
|
1368 | secure?: boolean
|
1369 | /** Explicitly specify if we are proxying to another proxy. */
|
1370 | toProxy?: boolean
|
1371 | /** Specify whether you want to prepend the target's path to the proxy path. */
|
1372 | prependPath?: boolean
|
1373 | /** Specify whether you want to ignore the proxy path of the incoming request. */
|
1374 | ignorePath?: boolean
|
1375 | /** Local interface string to bind for outgoing connections. */
|
1376 | localAddress?: string
|
1377 | /** Changes the origin of the host header to the target URL. */
|
1378 | changeOrigin?: boolean
|
1379 | /** specify whether you want to keep letter case of response header key */
|
1380 | preserveHeaderKeyCase?: boolean
|
1381 | /** Basic authentication i.e. 'user:password' to compute an Authorization header. */
|
1382 | auth?: string
|
1383 | /** Rewrites the location hostname on (301 / 302 / 307 / 308) redirects, Default: null. */
|
1384 | hostRewrite?: string
|
1385 | /** Rewrites the location host/ port on (301 / 302 / 307 / 308) redirects based on requested host/ port.Default: false. */
|
1386 | autoRewrite?: boolean
|
1387 | /** Rewrites the location protocol on (301 / 302 / 307 / 308) redirects to 'http' or 'https'.Default: null. */
|
1388 | protocolRewrite?: string
|
1389 | /** rewrites domain of set-cookie headers. */
|
1390 | cookieDomainRewrite?: false | string | { [oldDomain: string]: string }
|
1391 | /** rewrites path of set-cookie headers. Default: false */
|
1392 | cookiePathRewrite?: false | string | { [oldPath: string]: string }
|
1393 | /** object with extra headers to be added to target requests. */
|
1394 | headers?: { [header: string]: string }
|
1395 | /** Timeout (in milliseconds) when proxy receives no response from target. Default: 120000 (2 minutes) */
|
1396 | proxyTimeout?: number
|
1397 | /** Timeout (in milliseconds) for incoming requests */
|
1398 | timeout?: number
|
1399 | /** Specify whether you want to follow redirects. Default: false */
|
1400 | followRedirects?: boolean
|
1401 | /** If set to true, none of the webOutgoing passes are called and it's your responsibility to appropriately return the response by listening and acting on the proxyRes event */
|
1402 | selfHandleResponse?: boolean
|
1403 | /** Buffer */
|
1404 | buffer?: stream.Stream
|
1405 | }
|
1406 | }
|
1407 |
|
1408 | export declare type IndexHtmlTransform = IndexHtmlTransformHook | {
|
1409 | enforce?: 'pre' | 'post';
|
1410 | transform: IndexHtmlTransformHook;
|
1411 | };
|
1412 |
|
1413 | export declare interface IndexHtmlTransformContext {
|
1414 | /**
|
1415 | * public path when served
|
1416 | */
|
1417 | path: string;
|
1418 | /**
|
1419 | * filename on disk
|
1420 | */
|
1421 | filename: string;
|
1422 | server?: ViteDevServer;
|
1423 | bundle?: OutputBundle;
|
1424 | chunk?: OutputChunk;
|
1425 | originalUrl?: string;
|
1426 | }
|
1427 |
|
1428 | export declare type IndexHtmlTransformHook = (html: string, ctx: IndexHtmlTransformContext) => IndexHtmlTransformResult | void | Promise<IndexHtmlTransformResult | void>;
|
1429 |
|
1430 | export declare type IndexHtmlTransformResult = string | HtmlTagDescriptor[] | {
|
1431 | html: string;
|
1432 | tags: HtmlTagDescriptor[];
|
1433 | };
|
1434 |
|
1435 | export declare interface InlineConfig extends UserConfig {
|
1436 | configFile?: string | false;
|
1437 | envFile?: false;
|
1438 | }
|
1439 |
|
1440 | export declare interface InternalResolveOptions extends ResolveOptions {
|
1441 | root: string;
|
1442 | isBuild: boolean;
|
1443 | isProduction: boolean;
|
1444 | ssrTarget?: SSRTarget;
|
1445 | /**
|
1446 | * src code mode also attempts the following:
|
1447 | * - resolving /xxx as URLs
|
1448 | * - resolving bare imports from optimized deps
|
1449 | */
|
1450 | asSrc?: boolean;
|
1451 | tryIndex?: boolean;
|
1452 | tryPrefix?: string;
|
1453 | preferRelative?: boolean;
|
1454 | isRequire?: boolean;
|
1455 | }
|
1456 |
|
1457 | export declare interface JsonOptions {
|
1458 | /**
|
1459 | * Generate a named export for every property of the JSON object
|
1460 | * @default true
|
1461 | */
|
1462 | namedExports?: boolean;
|
1463 | /**
|
1464 | * Generate performant output as JSON.parse("stringified").
|
1465 | * Enabling this will disable namedExports.
|
1466 | * @default false
|
1467 | */
|
1468 | stringify?: boolean;
|
1469 | }
|
1470 |
|
1471 | export declare type LibraryFormats = 'es' | 'cjs' | 'umd' | 'iife';
|
1472 |
|
1473 | export declare interface LibraryOptions {
|
1474 | entry: string;
|
1475 | name?: string;
|
1476 | formats?: LibraryFormats[];
|
1477 | fileName?: string;
|
1478 | }
|
1479 |
|
1480 | export declare function loadConfigFromFile(configEnv: ConfigEnv, configFile?: string, configRoot?: string, logLevel?: LogLevel): Promise<{
|
1481 | path: string;
|
1482 | config: UserConfig;
|
1483 | dependencies: string[];
|
1484 | } | null>;
|
1485 |
|
1486 | export declare function loadEnv(mode: string, envDir: string, prefix?: string): Record<string, string>;
|
1487 |
|
1488 | export declare interface Logger {
|
1489 | info(msg: string, options?: LogOptions): void;
|
1490 | warn(msg: string, options?: LogOptions): void;
|
1491 | warnOnce(msg: string, options?: LogOptions): void;
|
1492 | error(msg: string, options?: LogOptions): void;
|
1493 | clearScreen(type: LogType): void;
|
1494 | hasWarned: boolean;
|
1495 | }
|
1496 |
|
1497 | export declare interface LoggerOptions {
|
1498 | prefix?: string;
|
1499 | allowClearScreen?: boolean;
|
1500 | }
|
1501 |
|
1502 | export declare type LogLevel = LogType | 'silent';
|
1503 |
|
1504 | export declare interface LogOptions {
|
1505 | clear?: boolean;
|
1506 | timestamp?: boolean;
|
1507 | }
|
1508 |
|
1509 | export declare type LogType = 'error' | 'warn' | 'info';
|
1510 |
|
1511 | export declare type Manifest = Record<string, ManifestChunk>;
|
1512 |
|
1513 | export declare interface ManifestChunk {
|
1514 | src?: string;
|
1515 | file: string;
|
1516 | css?: string[];
|
1517 | assets?: string[];
|
1518 | isEntry?: boolean;
|
1519 | isDynamicEntry?: boolean;
|
1520 | imports?: string[];
|
1521 | dynamicImports?: string[];
|
1522 | }
|
1523 |
|
1524 | export declare function mergeConfig(a: Record<string, any>, b: Record<string, any>, isRoot?: boolean): Record<string, any>;
|
1525 |
|
1526 | export declare class ModuleGraph {
|
1527 | urlToModuleMap: Map<string, ModuleNode>;
|
1528 | idToModuleMap: Map<string, ModuleNode>;
|
1529 | fileToModulesMap: Map<string, Set<ModuleNode>>;
|
1530 | safeModulesPath: Set<string>;
|
1531 | container: PluginContainer;
|
1532 | constructor(container: PluginContainer);
|
1533 | getModuleByUrl(rawUrl: string): Promise<ModuleNode | undefined>;
|
1534 | getModuleById(id: string): ModuleNode | undefined;
|
1535 | getModulesByFile(file: string): Set<ModuleNode> | undefined;
|
1536 | onFileChange(file: string): void;
|
1537 | invalidateModule(mod: ModuleNode, seen?: Set<ModuleNode>): void;
|
1538 | invalidateAll(): void;
|
1539 | /**
|
1540 | * Update the module graph based on a module's updated imports information
|
1541 | * If there are dependencies that no longer have any importers, they are
|
1542 | * returned as a Set.
|
1543 | */
|
1544 | updateModuleInfo(mod: ModuleNode, importedModules: Set<string | ModuleNode>, acceptedModules: Set<string | ModuleNode>, isSelfAccepting: boolean): Promise<Set<ModuleNode> | undefined>;
|
1545 | ensureEntryFromUrl(rawUrl: string): Promise<ModuleNode>;
|
1546 | createFileOnlyEntry(file: string): ModuleNode;
|
1547 | resolveUrl(url: string): Promise<[string, string]>;
|
1548 | }
|
1549 |
|
1550 | export declare class ModuleNode {
|
1551 | /**
|
1552 | * Public served url path, starts with /
|
1553 | */
|
1554 | url: string;
|
1555 | /**
|
1556 | * Resolved file system path + query
|
1557 | */
|
1558 | id: string | null;
|
1559 | file: string | null;
|
1560 | type: 'js' | 'css';
|
1561 | importers: Set<ModuleNode>;
|
1562 | importedModules: Set<ModuleNode>;
|
1563 | acceptedHmrDeps: Set<ModuleNode>;
|
1564 | isSelfAccepting: boolean;
|
1565 | transformResult: TransformResult | null;
|
1566 | ssrTransformResult: TransformResult | null;
|
1567 | ssrModule: Record<string, any> | null;
|
1568 | lastHMRTimestamp: number;
|
1569 | constructor(url: string);
|
1570 | }
|
1571 |
|
1572 | export declare function normalizePath(id: string): string;
|
1573 |
|
1574 | export declare function optimizeDeps(config: ResolvedConfig, force?: boolean | undefined, asCommand?: boolean, newDeps?: Record<string, string>, // missing imports encountered after server has started
|
1575 | ssr?: boolean): Promise<DepOptimizationMetadata | null>;
|
1576 |
|
1577 | export declare interface PackageData {
|
1578 | dir: string;
|
1579 | hasSideEffects: (id: string) => boolean;
|
1580 | webResolvedImports: Record<string, string | undefined>;
|
1581 | nodeResolvedImports: Record<string, string | undefined>;
|
1582 | setResolvedCache: (key: string, entry: string, targetWeb: boolean) => void;
|
1583 | getResolvedCache: (key: string, targetWeb: boolean) => string | undefined;
|
1584 | data: {
|
1585 | [field: string]: any;
|
1586 | version: string;
|
1587 | main: string;
|
1588 | module: string;
|
1589 | browser: string | Record<string, string | false>;
|
1590 | exports: string | Record<string, any> | string[];
|
1591 | dependencies: Record<string, string>;
|
1592 | };
|
1593 | }
|
1594 |
|
1595 | /**
|
1596 | * Vite plugins extends the Rollup plugin interface with a few extra
|
1597 | * vite-specific options. A valid vite plugin is also a valid Rollup plugin.
|
1598 | * On the contrary, a Rollup plugin may or may NOT be a valid vite universal
|
1599 | * plugin, since some Rollup features do not make sense in an unbundled
|
1600 | * dev server context. That said, as long as a rollup plugin doesn't have strong
|
1601 | * coupling between its bundle phase and output phase hooks then it should
|
1602 | * just work (that means, most of them).
|
1603 | *
|
1604 | * By default, the plugins are run during both serve and build. When a plugin
|
1605 | * is applied during serve, it will only run **non output plugin hooks** (see
|
1606 | * rollup type definition of {@link rollup#PluginHooks}). You can think of the
|
1607 | * dev server as only running `const bundle = rollup.rollup()` but never calling
|
1608 | * `bundle.generate()`.
|
1609 | *
|
1610 | * A plugin that expects to have different behavior depending on serve/build can
|
1611 | * export a factory function that receives the command being run via options.
|
1612 | *
|
1613 | * If a plugin should be applied only for server or build, a function format
|
1614 | * config file can be used to conditional determine the plugins to use.
|
1615 | */
|
1616 | export declare interface Plugin extends Plugin_2 {
|
1617 | /**
|
1618 | * Enforce plugin invocation tier similar to webpack loaders.
|
1619 | *
|
1620 | * Plugin invocation order:
|
1621 | * - alias resolution
|
1622 | * - `enforce: 'pre'` plugins
|
1623 | * - vite core plugins
|
1624 | * - normal plugins
|
1625 | * - vite build plugins
|
1626 | * - `enforce: 'post'` plugins
|
1627 | * - vite build post plugins
|
1628 | */
|
1629 | enforce?: 'pre' | 'post';
|
1630 | /**
|
1631 | * Apply the plugin only for serve or for build.
|
1632 | */
|
1633 | apply?: 'serve' | 'build';
|
1634 | /**
|
1635 | * Modify vite config before it's resolved. The hook can either mutate the
|
1636 | * passed-in config directly, or return a partial config object that will be
|
1637 | * deeply merged into existing config.
|
1638 | *
|
1639 | * Note: User plugins are resolved before running this hook so injecting other
|
1640 | * plugins inside the `config` hook will have no effect.
|
1641 | */
|
1642 | config?: (config: UserConfig, env: ConfigEnv) => UserConfig | null | void | Promise<UserConfig | null | void>;
|
1643 | /**
|
1644 | * Use this hook to read and store the final resolved vite config.
|
1645 | */
|
1646 | configResolved?: (config: ResolvedConfig) => void | Promise<void>;
|
1647 | /**
|
1648 | * Configure the vite server. The hook receives the {@link ViteDevServer}
|
1649 | * instance. This can also be used to store a reference to the server
|
1650 | * for use in other hooks.
|
1651 | *
|
1652 | * The hooks will be called before internal middlewares are applied. A hook
|
1653 | * can return a post hook that will be called after internal middlewares
|
1654 | * are applied. Hook can be async functions and will be called in series.
|
1655 | */
|
1656 | configureServer?: ServerHook;
|
1657 | /**
|
1658 | * Transform index.html.
|
1659 | * The hook receives the following arguments:
|
1660 | *
|
1661 | * - html: string
|
1662 | * - ctx?: vite.ServerContext (only present during serve)
|
1663 | * - bundle?: rollup.OutputBundle (only present during build)
|
1664 | *
|
1665 | * It can either return a transformed string, or a list of html tag
|
1666 | * descriptors that will be injected into the <head> or <body>.
|
1667 | *
|
1668 | * By default the transform is applied **after** vite's internal html
|
1669 | * transform. If you need to apply the transform before vite, use an object:
|
1670 | * `{ enforce: 'pre', transform: hook }`
|
1671 | */
|
1672 | transformIndexHtml?: IndexHtmlTransform;
|
1673 | /**
|
1674 | * Perform custom handling of HMR updates.
|
1675 | * The handler receives a context containing changed filename, timestamp, a
|
1676 | * list of modules affected by the file change, and the dev server instance.
|
1677 | *
|
1678 | * - The hook can return a filtered list of modules to narrow down the update.
|
1679 | * e.g. for a Vue SFC, we can narrow down the part to update by comparing
|
1680 | * the descriptors.
|
1681 | *
|
1682 | * - The hook can also return an empty array and then perform custom updates
|
1683 | * by sending a custom hmr payload via server.ws.send().
|
1684 | *
|
1685 | * - If the hook doesn't return a value, the hmr update will be performed as
|
1686 | * normal.
|
1687 | */
|
1688 | handleHotUpdate?(ctx: HmrContext): Array<ModuleNode> | void | Promise<Array<ModuleNode> | void>;
|
1689 | /**
|
1690 | * extend hooks with ssr flag
|
1691 | */
|
1692 | resolveId?(this: PluginContext, source: string, importer: string | undefined, options: {
|
1693 | custom?: CustomPluginOptions;
|
1694 | }, ssr?: boolean): Promise<ResolveIdResult> | ResolveIdResult;
|
1695 | load?(this: PluginContext, id: string, ssr?: boolean): Promise<LoadResult> | LoadResult;
|
1696 | transform?(this: TransformPluginContext, code: string, id: string, ssr?: boolean): Promise<TransformResult_2> | TransformResult_2;
|
1697 | }
|
1698 |
|
1699 | export declare interface PluginContainer {
|
1700 | options: InputOptions;
|
1701 | buildStart(options: InputOptions): Promise<void>;
|
1702 | watchChange(id: string, event?: ChangeEvent): void;
|
1703 | resolveId(id: string, importer?: string, skip?: Set<Plugin>, ssr?: boolean): Promise<PartialResolvedId | null>;
|
1704 | transform(code: string, id: string, inMap?: SourceDescription['map'], ssr?: boolean): Promise<SourceDescription | null>;
|
1705 | load(id: string, ssr?: boolean): Promise<LoadResult | null>;
|
1706 | close(): Promise<void>;
|
1707 | }
|
1708 |
|
1709 | export declare type PluginOption = Plugin | false | null | undefined;
|
1710 |
|
1711 | export declare interface ProxyOptions extends HttpProxy.ServerOptions {
|
1712 | /**
|
1713 | * rewrite path
|
1714 | */
|
1715 | rewrite?: (path: string) => string;
|
1716 | /**
|
1717 | * configure the proxy server (e.g. listen to events)
|
1718 | */
|
1719 | configure?: (proxy: HttpProxy.Server, options: ProxyOptions) => void;
|
1720 | /**
|
1721 | * webpack-dev-server style bypass function
|
1722 | */
|
1723 | bypass?: (req: http.IncomingMessage, res: http.ServerResponse, options: ProxyOptions) => void | null | undefined | false | string;
|
1724 | }
|
1725 |
|
1726 | export declare interface PrunePayload {
|
1727 | type: 'prune'
|
1728 | paths: string[]
|
1729 | }
|
1730 |
|
1731 | export declare function resolveConfig(inlineConfig: InlineConfig, command: 'build' | 'serve', defaultMode?: string): Promise<ResolvedConfig>;
|
1732 |
|
1733 | export declare type ResolvedBuildOptions = Required<Omit<BuildOptions, 'base'>>;
|
1734 |
|
1735 | export declare type ResolvedConfig = Readonly<Omit<UserConfig, 'plugins' | 'alias' | 'dedupe' | 'assetsInclude' | 'optimizeDeps'> & {
|
1736 | configFile: string | undefined;
|
1737 | configFileDependencies: string[];
|
1738 | inlineConfig: InlineConfig;
|
1739 | root: string;
|
1740 | base: string;
|
1741 | publicDir: string;
|
1742 | command: 'build' | 'serve';
|
1743 | mode: string;
|
1744 | isProduction: boolean;
|
1745 | env: Record<string, any>;
|
1746 | resolve: ResolveOptions & {
|
1747 | alias: Alias[];
|
1748 | };
|
1749 | plugins: readonly Plugin[];
|
1750 | server: ResolvedServerOptions;
|
1751 | build: ResolvedBuildOptions;
|
1752 | assetsInclude: (file: string) => boolean;
|
1753 | logger: Logger;
|
1754 | createResolver: (options?: Partial<InternalResolveOptions>) => ResolveFn;
|
1755 | optimizeDeps: Omit<DepOptimizationOptions, 'keepNames'>;
|
1756 | }>;
|
1757 |
|
1758 | export declare interface ResolvedServerOptions extends ServerOptions {
|
1759 | fs: Required<FileSystemServeOptions>;
|
1760 | }
|
1761 |
|
1762 | export declare type ResolveFn = (id: string, importer?: string, aliasOnly?: boolean, ssr?: boolean) => Promise<string | undefined>;
|
1763 |
|
1764 | export declare interface ResolveOptions {
|
1765 | mainFields?: string[];
|
1766 | conditions?: string[];
|
1767 | extensions?: string[];
|
1768 | dedupe?: string[];
|
1769 | }
|
1770 |
|
1771 | export declare function resolvePackageData(id: string, basedir: string): PackageData | undefined;
|
1772 |
|
1773 | export declare function resolvePackageEntry(id: string, { dir, data, setResolvedCache, getResolvedCache }: PackageData, options: InternalResolveOptions, targetWeb: boolean): string | undefined;
|
1774 |
|
1775 | export declare type ResolverFunction = PluginHooks['resolveId']
|
1776 |
|
1777 | export declare interface ResolverObject {
|
1778 | buildStart?: PluginHooks['buildStart']
|
1779 | resolveId: ResolverFunction
|
1780 | }
|
1781 |
|
1782 | /**
|
1783 | * https://github.com/rollup/plugins/blob/master/packages/commonjs/types/index.d.ts
|
1784 | *
|
1785 | * This source code is licensed under the MIT license found in the
|
1786 | * LICENSE file at
|
1787 | * https://github.com/rollup/plugins/blob/master/LICENSE
|
1788 | */
|
1789 | export declare interface RollupCommonJSOptions {
|
1790 | /**
|
1791 | * A minimatch pattern, or array of patterns, which specifies the files in
|
1792 | * the build the plugin should operate on. By default, all files with
|
1793 | * extension `".cjs"` or those in `extensions` are included, but you can narrow
|
1794 | * this list by only including specific files. These files will be analyzed
|
1795 | * and transpiled if either the analysis does not find ES module specific
|
1796 | * statements or `transformMixedEsModules` is `true`.
|
1797 | * @default undefined
|
1798 | */
|
1799 | include?: string | RegExp | readonly (string | RegExp)[]
|
1800 | /**
|
1801 | * A minimatch pattern, or array of patterns, which specifies the files in
|
1802 | * the build the plugin should _ignore_. By default, all files with
|
1803 | * extensions other than those in `extensions` or `".cjs"` are ignored, but you
|
1804 | * can exclude additional files. See also the `include` option.
|
1805 | * @default undefined
|
1806 | */
|
1807 | exclude?: string | RegExp | readonly (string | RegExp)[]
|
1808 | /**
|
1809 | * For extensionless imports, search for extensions other than .js in the
|
1810 | * order specified. Note that you need to make sure that non-JavaScript files
|
1811 | * are transpiled by another plugin first.
|
1812 | * @default [ '.js' ]
|
1813 | */
|
1814 | extensions?: ReadonlyArray<string>
|
1815 | /**
|
1816 | * If true then uses of `global` won't be dealt with by this plugin
|
1817 | * @default false
|
1818 | */
|
1819 | ignoreGlobal?: boolean
|
1820 | /**
|
1821 | * If false, skips source map generation for CommonJS modules. This will improve performance.
|
1822 | * @default true
|
1823 | */
|
1824 | sourceMap?: boolean
|
1825 | /**
|
1826 | * Some `require` calls cannot be resolved statically to be translated to
|
1827 | * imports.
|
1828 | * When this option is set to `false`, the generated code will either
|
1829 | * directly throw an error when such a call is encountered or, when
|
1830 | * `dynamicRequireTargets` is used, when such a call cannot be resolved with a
|
1831 | * configured dynamic require target.
|
1832 | * Setting this option to `true` will instead leave the `require` call in the
|
1833 | * code or use it as a fallback for `dynamicRequireTargets`.
|
1834 | * @default false
|
1835 | */
|
1836 | ignoreDynamicRequires?: boolean
|
1837 | /**
|
1838 | * Instructs the plugin whether to enable mixed module transformations. This
|
1839 | * is useful in scenarios with modules that contain a mix of ES `import`
|
1840 | * statements and CommonJS `require` expressions. Set to `true` if `require`
|
1841 | * calls should be transformed to imports in mixed modules, or `false` if the
|
1842 | * `require` expressions should survive the transformation. The latter can be
|
1843 | * important if the code contains environment detection, or you are coding
|
1844 | * for an environment with special treatment for `require` calls such as
|
1845 | * ElectronJS. See also the `ignore` option.
|
1846 | * @default false
|
1847 | */
|
1848 | transformMixedEsModules?: boolean
|
1849 | /**
|
1850 | * Sometimes you have to leave require statements unconverted. Pass an array
|
1851 | * containing the IDs or a `id => boolean` function.
|
1852 | * @default []
|
1853 | */
|
1854 | ignore?: ReadonlyArray<string> | ((id: string) => boolean)
|
1855 | /**
|
1856 | * Controls how to render imports from external dependencies. By default,
|
1857 | * this plugin assumes that all external dependencies are CommonJS. This
|
1858 | * means they are rendered as default imports to be compatible with e.g.
|
1859 | * NodeJS where ES modules can only import a default export from a CommonJS
|
1860 | * dependency.
|
1861 | *
|
1862 | * If you set `esmExternals` to `true`, this plugins assumes that all
|
1863 | * external dependencies are ES modules and respect the
|
1864 | * `requireReturnsDefault` option. If that option is not set, they will be
|
1865 | * rendered as namespace imports.
|
1866 | *
|
1867 | * You can also supply an array of ids to be treated as ES modules, or a
|
1868 | * function that will be passed each external id to determine if it is an ES
|
1869 | * module.
|
1870 | * @default false
|
1871 | */
|
1872 | esmExternals?: boolean | ReadonlyArray<string> | ((id: string) => boolean)
|
1873 | /**
|
1874 | * Controls what is returned when requiring an ES module from a CommonJS file.
|
1875 | * When using the `esmExternals` option, this will also apply to external
|
1876 | * modules. By default, this plugin will render those imports as namespace
|
1877 | * imports i.e.
|
1878 | *
|
1879 | * ```js
|
1880 | * // input
|
1881 | * const foo = require('foo');
|
1882 | *
|
1883 | * // output
|
1884 | * import * as foo from 'foo';
|
1885 | * ```
|
1886 | *
|
1887 | * However there are some situations where this may not be desired.
|
1888 | * For these situations, you can change Rollup's behaviour either globally or
|
1889 | * per module. To change it globally, set the `requireReturnsDefault` option
|
1890 | * to one of the following values:
|
1891 | *
|
1892 | * - `false`: This is the default, requiring an ES module returns its
|
1893 | * namespace. This is the only option that will also add a marker
|
1894 | * `__esModule: true` to the namespace to support interop patterns in
|
1895 | * CommonJS modules that are transpiled ES modules.
|
1896 | * - `"namespace"`: Like `false`, requiring an ES module returns its
|
1897 | * namespace, but the plugin does not add the `__esModule` marker and thus
|
1898 | * creates more efficient code. For external dependencies when using
|
1899 | * `esmExternals: true`, no additional interop code is generated.
|
1900 | * - `"auto"`: This is complementary to how `output.exports: "auto"` works in
|
1901 | * Rollup: If a module has a default export and no named exports, requiring
|
1902 | * that module returns the default export. In all other cases, the namespace
|
1903 | * is returned. For external dependencies when using `esmExternals: true`, a
|
1904 | * corresponding interop helper is added.
|
1905 | * - `"preferred"`: If a module has a default export, requiring that module
|
1906 | * always returns the default export, no matter whether additional named
|
1907 | * exports exist. This is similar to how previous versions of this plugin
|
1908 | * worked. Again for external dependencies when using `esmExternals: true`,
|
1909 | * an interop helper is added.
|
1910 | * - `true`: This will always try to return the default export on require
|
1911 | * without checking if it actually exists. This can throw at build time if
|
1912 | * there is no default export. This is how external dependencies are handled
|
1913 | * when `esmExternals` is not used. The advantage over the other options is
|
1914 | * that, like `false`, this does not add an interop helper for external
|
1915 | * dependencies, keeping the code lean.
|
1916 | *
|
1917 | * To change this for individual modules, you can supply a function for
|
1918 | * `requireReturnsDefault` instead. This function will then be called once for
|
1919 | * each required ES module or external dependency with the corresponding id
|
1920 | * and allows you to return different values for different modules.
|
1921 | * @default false
|
1922 | */
|
1923 | requireReturnsDefault?:
|
1924 | | boolean
|
1925 | | 'auto'
|
1926 | | 'preferred'
|
1927 | | 'namespace'
|
1928 | | ((id: string) => boolean | 'auto' | 'preferred' | 'namespace')
|
1929 | /**
|
1930 | * Some modules contain dynamic `require` calls, or require modules that
|
1931 | * contain circular dependencies, which are not handled well by static
|
1932 | * imports. Including those modules as `dynamicRequireTargets` will simulate a
|
1933 | * CommonJS (NodeJS-like) environment for them with support for dynamic and
|
1934 | * circular dependencies.
|
1935 | *
|
1936 | * Note: In extreme cases, this feature may result in some paths being
|
1937 | * rendered as absolute in the final bundle. The plugin tries to avoid
|
1938 | * exposing paths from the local machine, but if you are `dynamicRequirePaths`
|
1939 | * with paths that are far away from your project's folder, that may require
|
1940 | * replacing strings like `"/Users/John/Desktop/foo-project/"` -\> `"/"`.
|
1941 | */
|
1942 | dynamicRequireTargets?: string | ReadonlyArray<string>
|
1943 | }
|
1944 |
|
1945 | export declare interface RollupDynamicImportVarsOptions {
|
1946 | /**
|
1947 | * Files to include in this plugin (default all).
|
1948 | * @default []
|
1949 | */
|
1950 | include?: string | RegExp | (string | RegExp)[]
|
1951 | /**
|
1952 | * Files to exclude in this plugin (default none).
|
1953 | * @default []
|
1954 | */
|
1955 | exclude?: string | RegExp | (string | RegExp)[]
|
1956 | /**
|
1957 | * By default, the plugin quits the build process when it encounters an error. If you set this option to true, it will throw a warning instead and leave the code untouched.
|
1958 | * @default false
|
1959 | */
|
1960 | warnOnError?: boolean
|
1961 | }
|
1962 |
|
1963 | export declare function send(req: IncomingMessage, res: ServerResponse, content: string | Buffer, type: string, etag?: string, cacheControl?: string, map?: SourceMap | null): void;
|
1964 |
|
1965 | export declare type ServerHook = (server: ViteDevServer) => (() => void) | void | Promise<(() => void) | void>;
|
1966 |
|
1967 | export declare interface ServerOptions {
|
1968 | host?: string | boolean;
|
1969 | port?: number;
|
1970 | /**
|
1971 | * Enable TLS + HTTP/2.
|
1972 | * Note: this downgrades to TLS only when the proxy option is also used.
|
1973 | */
|
1974 | https?: boolean | https.ServerOptions;
|
1975 | /**
|
1976 | * Open browser window on startup
|
1977 | */
|
1978 | open?: boolean | string;
|
1979 | /**
|
1980 | * Force dep pre-optimization regardless of whether deps have changed.
|
1981 | */
|
1982 | force?: boolean;
|
1983 | /**
|
1984 | * Configure HMR-specific options (port, host, path & protocol)
|
1985 | */
|
1986 | hmr?: HmrOptions | boolean;
|
1987 | /**
|
1988 | * chokidar watch options
|
1989 | * https://github.com/paulmillr/chokidar#api
|
1990 | */
|
1991 | watch?: WatchOptions;
|
1992 | /**
|
1993 | * Configure custom proxy rules for the dev server. Expects an object
|
1994 | * of `{ key: options }` pairs.
|
1995 | * Uses [`http-proxy`](https://github.com/http-party/node-http-proxy).
|
1996 | * Full options [here](https://github.com/http-party/node-http-proxy#options).
|
1997 | *
|
1998 | * Example `vite.config.js`:
|
1999 | * ``` js
|
2000 | * module.exports = {
|
2001 | * proxy: {
|
2002 | * // string shorthand
|
2003 | * '/foo': 'http://localhost:4567/foo',
|
2004 | * // with options
|
2005 | * '/api': {
|
2006 | * target: 'http://jsonplaceholder.typicode.com',
|
2007 | * changeOrigin: true,
|
2008 | * rewrite: path => path.replace(/^\/api/, '')
|
2009 | * }
|
2010 | * }
|
2011 | * }
|
2012 | * ```
|
2013 | */
|
2014 | proxy?: Record<string, string | ProxyOptions>;
|
2015 | /**
|
2016 | * Configure CORS for the dev server.
|
2017 | * Uses https://github.com/expressjs/cors.
|
2018 | * Set to `true` to allow all methods from any origin, or configure separately
|
2019 | * using an object.
|
2020 | */
|
2021 | cors?: CorsOptions | boolean;
|
2022 | /**
|
2023 | * If enabled, vite will exit if specified port is already in use
|
2024 | */
|
2025 | strictPort?: boolean;
|
2026 | /**
|
2027 | * Create Vite dev server to be used as a middleware in an existing server
|
2028 | */
|
2029 | middlewareMode?: boolean | 'html' | 'ssr';
|
2030 | /**
|
2031 | * Prepend this folder to http requests, for use when proxying vite as a subfolder
|
2032 | * Should start and end with the `/` character
|
2033 | */
|
2034 | base?: string;
|
2035 | /**
|
2036 | * Options for files served via '/\@fs/'.
|
2037 | */
|
2038 | fs?: FileSystemServeOptions;
|
2039 | }
|
2040 |
|
2041 | export declare function sortUserPlugins(plugins: (Plugin | Plugin[])[] | undefined): [Plugin[], Plugin[], Plugin[]];
|
2042 |
|
2043 | export declare interface SSROptions {
|
2044 | external?: string[];
|
2045 | noExternal?: string | RegExp | (string | RegExp)[];
|
2046 | /**
|
2047 | * Define the target for the ssr build. The browser field in package.json
|
2048 | * is ignored for node but used if webworker is the target
|
2049 | * Default: 'node'
|
2050 | */
|
2051 | target?: SSRTarget;
|
2052 | }
|
2053 |
|
2054 | export declare type SSRTarget = 'node' | 'webworker';
|
2055 |
|
2056 | export declare namespace Terser {
|
2057 | export type ECMA = 5 | 2015 | 2016 | 2017 | 2018 | 2019 | 2020
|
2058 |
|
2059 | export interface ParseOptions {
|
2060 | bare_returns?: boolean
|
2061 | ecma?: ECMA
|
2062 | html5_comments?: boolean
|
2063 | shebang?: boolean
|
2064 | }
|
2065 |
|
2066 | export interface CompressOptions {
|
2067 | arguments?: boolean
|
2068 | arrows?: boolean
|
2069 | booleans_as_integers?: boolean
|
2070 | booleans?: boolean
|
2071 | collapse_vars?: boolean
|
2072 | comparisons?: boolean
|
2073 | computed_props?: boolean
|
2074 | conditionals?: boolean
|
2075 | dead_code?: boolean
|
2076 | defaults?: boolean
|
2077 | directives?: boolean
|
2078 | drop_console?: boolean
|
2079 | drop_debugger?: boolean
|
2080 | ecma?: ECMA
|
2081 | evaluate?: boolean
|
2082 | expression?: boolean
|
2083 | global_defs?: object
|
2084 | hoist_funs?: boolean
|
2085 | hoist_props?: boolean
|
2086 | hoist_vars?: boolean
|
2087 | ie8?: boolean
|
2088 | if_return?: boolean
|
2089 | inline?: boolean | InlineFunctions
|
2090 | join_vars?: boolean
|
2091 | keep_classnames?: boolean | RegExp
|
2092 | keep_fargs?: boolean
|
2093 | keep_fnames?: boolean | RegExp
|
2094 | keep_infinity?: boolean
|
2095 | loops?: boolean
|
2096 | module?: boolean
|
2097 | negate_iife?: boolean
|
2098 | passes?: number
|
2099 | properties?: boolean
|
2100 | pure_funcs?: string[]
|
2101 | pure_getters?: boolean | 'strict'
|
2102 | reduce_funcs?: boolean
|
2103 | reduce_vars?: boolean
|
2104 | sequences?: boolean | number
|
2105 | side_effects?: boolean
|
2106 | switches?: boolean
|
2107 | toplevel?: boolean
|
2108 | top_retain?: null | string | string[] | RegExp
|
2109 | typeofs?: boolean
|
2110 | unsafe_arrows?: boolean
|
2111 | unsafe?: boolean
|
2112 | unsafe_comps?: boolean
|
2113 | unsafe_Function?: boolean
|
2114 | unsafe_math?: boolean
|
2115 | unsafe_symbols?: boolean
|
2116 | unsafe_methods?: boolean
|
2117 | unsafe_proto?: boolean
|
2118 | unsafe_regexp?: boolean
|
2119 | unsafe_undefined?: boolean
|
2120 | unused?: boolean
|
2121 | }
|
2122 |
|
2123 | export enum InlineFunctions {
|
2124 | Disabled = 0,
|
2125 | SimpleFunctions = 1,
|
2126 | WithArguments = 2,
|
2127 | WithArgumentsAndVariables = 3
|
2128 | }
|
2129 |
|
2130 | export interface MangleOptions {
|
2131 | eval?: boolean
|
2132 | keep_classnames?: boolean | RegExp
|
2133 | keep_fnames?: boolean | RegExp
|
2134 | module?: boolean
|
2135 | properties?: boolean | ManglePropertiesOptions
|
2136 | reserved?: string[]
|
2137 | safari10?: boolean
|
2138 | toplevel?: boolean
|
2139 | }
|
2140 |
|
2141 | export interface ManglePropertiesOptions {
|
2142 | builtins?: boolean
|
2143 | debug?: boolean
|
2144 | keep_quoted?: boolean | 'strict'
|
2145 | regex?: RegExp | string
|
2146 | reserved?: string[]
|
2147 | }
|
2148 |
|
2149 | export interface FormatOptions {
|
2150 | ascii_only?: boolean
|
2151 | beautify?: boolean
|
2152 | braces?: boolean
|
2153 | comments?:
|
2154 | | boolean
|
2155 | | 'all'
|
2156 | | 'some'
|
2157 | | RegExp
|
2158 | | ((
|
2159 | node: any,
|
2160 | comment: {
|
2161 | value: string
|
2162 | type: 'comment1' | 'comment2' | 'comment3' | 'comment4'
|
2163 | pos: number
|
2164 | line: number
|
2165 | col: number
|
2166 | }
|
2167 | ) => boolean)
|
2168 | ecma?: ECMA
|
2169 | ie8?: boolean
|
2170 | indent_level?: number
|
2171 | indent_start?: number
|
2172 | inline_script?: boolean
|
2173 | keep_quoted_props?: boolean
|
2174 | max_line_len?: number | false
|
2175 | preamble?: string
|
2176 | preserve_annotations?: boolean
|
2177 | quote_keys?: boolean
|
2178 | quote_style?: OutputQuoteStyle
|
2179 | safari10?: boolean
|
2180 | semicolons?: boolean
|
2181 | shebang?: boolean
|
2182 | shorthand?: boolean
|
2183 | source_map?: SourceMapOptions
|
2184 | webkit?: boolean
|
2185 | width?: number
|
2186 | wrap_iife?: boolean
|
2187 | wrap_func_args?: boolean
|
2188 | }
|
2189 |
|
2190 | export enum OutputQuoteStyle {
|
2191 | PreferDouble = 0,
|
2192 | AlwaysSingle = 1,
|
2193 | AlwaysDouble = 2,
|
2194 | AlwaysOriginal = 3
|
2195 | }
|
2196 |
|
2197 | export interface MinifyOptions {
|
2198 | compress?: boolean | CompressOptions
|
2199 | ecma?: ECMA
|
2200 | ie8?: boolean
|
2201 | keep_classnames?: boolean | RegExp
|
2202 | keep_fnames?: boolean | RegExp
|
2203 | mangle?: boolean | MangleOptions
|
2204 | module?: boolean
|
2205 | nameCache?: object
|
2206 | format?: FormatOptions
|
2207 | /** @deprecated use format instead */
|
2208 | output?: FormatOptions
|
2209 | parse?: ParseOptions
|
2210 | safari10?: boolean
|
2211 | sourceMap?: boolean | SourceMapOptions
|
2212 | toplevel?: boolean
|
2213 | }
|
2214 |
|
2215 | export interface MinifyOutput {
|
2216 | code?: string
|
2217 | map?: object | string
|
2218 | }
|
2219 |
|
2220 | export interface SourceMapOptions {
|
2221 | /** Source map object, 'inline' or source map file content */
|
2222 | content?: object | string
|
2223 | includeSources?: boolean
|
2224 | filename?: string
|
2225 | root?: string
|
2226 | url?: string | 'inline'
|
2227 | }
|
2228 | }
|
2229 |
|
2230 | export declare interface TransformOptions {
|
2231 | ssr?: boolean;
|
2232 | html?: boolean;
|
2233 | }
|
2234 |
|
2235 | export declare interface TransformResult {
|
2236 | code: string;
|
2237 | map: SourceMap | null;
|
2238 | etag?: string;
|
2239 | deps?: string[];
|
2240 | }
|
2241 |
|
2242 | export declare interface Update {
|
2243 | type: 'js-update' | 'css-update'
|
2244 | path: string
|
2245 | acceptedPath: string
|
2246 | timestamp: number
|
2247 | }
|
2248 |
|
2249 | export declare interface UpdatePayload {
|
2250 | type: 'update'
|
2251 | updates: Update[]
|
2252 | }
|
2253 |
|
2254 | export declare interface UserConfig {
|
2255 | /**
|
2256 | * Project root directory. Can be an absolute path, or a path relative from
|
2257 | * the location of the config file itself.
|
2258 | * @default process.cwd()
|
2259 | */
|
2260 | root?: string;
|
2261 | /**
|
2262 | * Base public path when served in development or production.
|
2263 | * @default '/'
|
2264 | */
|
2265 | base?: string;
|
2266 | /**
|
2267 | * Directory to serve as plain static assets. Files in this directory are
|
2268 | * served and copied to build dist dir as-is without transform. The value
|
2269 | * can be either an absolute file system path or a path relative to <root>.
|
2270 | *
|
2271 | * Set to `false` or an empty string to disable copied static assets to build dist dir.
|
2272 | * @default 'public'
|
2273 | */
|
2274 | publicDir?: string | false;
|
2275 | /**
|
2276 | * Directory to save cache files. Files in this directory are pre-bundled
|
2277 | * deps or some other cache files that generated by vite, which can improve
|
2278 | * the performance. You can use `--force` flag or manually delete the directory
|
2279 | * to regenerate the cache files. The value can be either an absolute file
|
2280 | * system path or a path relative to <root>.
|
2281 | * @default 'node_modules/.vite'
|
2282 | */
|
2283 | cacheDir?: string;
|
2284 | /**
|
2285 | * Explicitly set a mode to run in. This will override the default mode for
|
2286 | * each command, and can be overridden by the command line --mode option.
|
2287 | */
|
2288 | mode?: string;
|
2289 | /**
|
2290 | * Define global variable replacements.
|
2291 | * Entries will be defined on `window` during dev and replaced during build.
|
2292 | */
|
2293 | define?: Record<string, any>;
|
2294 | /**
|
2295 | * Array of vite plugins to use.
|
2296 | */
|
2297 | plugins?: (PluginOption | PluginOption[])[];
|
2298 | /**
|
2299 | * Configure resolver
|
2300 | */
|
2301 | resolve?: ResolveOptions & {
|
2302 | alias?: AliasOptions;
|
2303 | };
|
2304 | /**
|
2305 | * CSS related options (preprocessors and CSS modules)
|
2306 | */
|
2307 | css?: CSSOptions;
|
2308 | /**
|
2309 | * JSON loading options
|
2310 | */
|
2311 | json?: JsonOptions;
|
2312 | /**
|
2313 | * Transform options to pass to esbuild.
|
2314 | * Or set to `false` to disable esbuild.
|
2315 | */
|
2316 | esbuild?: ESBuildOptions | false;
|
2317 | /**
|
2318 | * Specify additional files to be treated as static assets.
|
2319 | */
|
2320 | assetsInclude?: string | RegExp | (string | RegExp)[];
|
2321 | /**
|
2322 | * Server specific options, e.g. host, port, https...
|
2323 | */
|
2324 | server?: ServerOptions;
|
2325 | /**
|
2326 | * Build specific options
|
2327 | */
|
2328 | build?: BuildOptions;
|
2329 | /**
|
2330 | * Dep optimization options
|
2331 | */
|
2332 | optimizeDeps?: DepOptimizationOptions;
|
2333 | /* Excluded from this release type: ssr */
|
2334 | /**
|
2335 | * Log level.
|
2336 | * Default: 'info'
|
2337 | */
|
2338 | logLevel?: LogLevel;
|
2339 | /**
|
2340 | * Default: true
|
2341 | */
|
2342 | clearScreen?: boolean;
|
2343 | /**
|
2344 | * Environment files directory. Can be an absolute path, or a path relative from
|
2345 | * the location of the config file itself.
|
2346 | * @default root
|
2347 | */
|
2348 | envDir?: string;
|
2349 | /**
|
2350 | * Import aliases
|
2351 | * @deprecated use `resolve.alias` instead
|
2352 | */
|
2353 | alias?: AliasOptions;
|
2354 | /**
|
2355 | * Force Vite to always resolve listed dependencies to the same copy (from
|
2356 | * project root).
|
2357 | * @deprecated use `resolve.dedupe` instead
|
2358 | */
|
2359 | dedupe?: string[];
|
2360 | }
|
2361 |
|
2362 | export declare type UserConfigExport = UserConfig | Promise<UserConfig> | UserConfigFn;
|
2363 |
|
2364 | export declare type UserConfigFn = (env: ConfigEnv) => UserConfig | Promise<UserConfig>;
|
2365 |
|
2366 | export declare interface ViteDevServer {
|
2367 | /**
|
2368 | * The resolved vite config object
|
2369 | */
|
2370 | config: ResolvedConfig;
|
2371 | /**
|
2372 | * A connect app instance.
|
2373 | * - Can be used to attach custom middlewares to the dev server.
|
2374 | * - Can also be used as the handler function of a custom http server
|
2375 | * or as a middleware in any connect-style Node.js frameworks
|
2376 | *
|
2377 | * https://github.com/senchalabs/connect#use-middleware
|
2378 | */
|
2379 | middlewares: Connect.Server;
|
2380 | /**
|
2381 | * @deprecated use `server.middlewares` instead
|
2382 | */
|
2383 | app: Connect.Server;
|
2384 | /**
|
2385 | * native Node http server instance
|
2386 | * will be null in middleware mode
|
2387 | */
|
2388 | httpServer: http.Server | null;
|
2389 | /**
|
2390 | * chokidar watcher instance
|
2391 | * https://github.com/paulmillr/chokidar#api
|
2392 | */
|
2393 | watcher: FSWatcher;
|
2394 | /**
|
2395 | * web socket server with `send(payload)` method
|
2396 | */
|
2397 | ws: WebSocketServer;
|
2398 | /**
|
2399 | * Rollup plugin container that can run plugin hooks on a given file
|
2400 | */
|
2401 | pluginContainer: PluginContainer;
|
2402 | /**
|
2403 | * Module graph that tracks the import relationships, url to file mapping
|
2404 | * and hmr state.
|
2405 | */
|
2406 | moduleGraph: ModuleGraph;
|
2407 | /**
|
2408 | * Programmatically resolve, load and transform a URL and get the result
|
2409 | * without going through the http request pipeline.
|
2410 | */
|
2411 | transformRequest(url: string, options?: TransformOptions): Promise<TransformResult_2 | null>;
|
2412 | /**
|
2413 | * Apply vite built-in HTML transforms and any plugin HTML transforms.
|
2414 | */
|
2415 | transformIndexHtml(url: string, html: string, originalUrl?: string): Promise<string>;
|
2416 | /**
|
2417 | * Util for transforming a file with esbuild.
|
2418 | * Can be useful for certain plugins.
|
2419 | */
|
2420 | transformWithEsbuild(code: string, filename: string, options?: TransformOptions_2, inMap?: object): Promise<ESBuildTransformResult>;
|
2421 | /**
|
2422 | * Load a given URL as an instantiated module for SSR.
|
2423 | */
|
2424 | ssrLoadModule(url: string): Promise<Record<string, any>>;
|
2425 | /**
|
2426 | * Fix ssr error stacktrace
|
2427 | */
|
2428 | ssrFixStacktrace(e: Error): void;
|
2429 | /**
|
2430 | * Start the server.
|
2431 | */
|
2432 | listen(port?: number, isRestart?: boolean): Promise<ViteDevServer>;
|
2433 | /**
|
2434 | * Stop the server.
|
2435 | */
|
2436 | close(): Promise<void>;
|
2437 | /* Excluded from this release type: _optimizeDepsMetadata */
|
2438 | /* Excluded from this release type: _ssrExternals */
|
2439 | /* Excluded from this release type: _globImporters */
|
2440 | /* Excluded from this release type: _isRunningOptimizer */
|
2441 | /* Excluded from this release type: _registerMissingImport */
|
2442 | /* Excluded from this release type: _pendingReload */
|
2443 | }
|
2444 |
|
2445 | export declare interface WatchOptions {
|
2446 | /**
|
2447 | * Indicates whether the process should continue to run as long as files are being watched. If
|
2448 | * set to `false` when using `fsevents` to watch, no more events will be emitted after `ready`,
|
2449 | * even if the process continues to run.
|
2450 | */
|
2451 | persistent?: boolean
|
2452 |
|
2453 | /**
|
2454 | * ([anymatch](https://github.com/micromatch/anymatch)-compatible definition) Defines files/paths to
|
2455 | * be ignored. The whole relative or absolute path is tested, not just filename. If a function
|
2456 | * with two arguments is provided, it gets called twice per path - once with a single argument
|
2457 | * (the path), second time with two arguments (the path and the
|
2458 | * [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
|
2459 | */
|
2460 | ignored?: any
|
2461 |
|
2462 | /**
|
2463 | * If set to `false` then `add`/`addDir` events are also emitted for matching paths while
|
2464 | * instantiating the watching as chokidar discovers these file paths (before the `ready` event).
|
2465 | */
|
2466 | ignoreInitial?: boolean
|
2467 |
|
2468 | /**
|
2469 | * When `false`, only the symlinks themselves will be watched for changes instead of following
|
2470 | * the link references and bubbling events through the link's path.
|
2471 | */
|
2472 | followSymlinks?: boolean
|
2473 |
|
2474 | /**
|
2475 | * The base directory from which watch `paths` are to be derived. Paths emitted with events will
|
2476 | * be relative to this.
|
2477 | */
|
2478 | cwd?: string
|
2479 |
|
2480 | /**
|
2481 | * If set to true then the strings passed to .watch() and .add() are treated as literal path
|
2482 | * names, even if they look like globs. Default: false.
|
2483 | */
|
2484 | disableGlobbing?: boolean
|
2485 |
|
2486 | /**
|
2487 | * Whether to use fs.watchFile (backed by polling), or fs.watch. If polling leads to high CPU
|
2488 | * utilization, consider setting this to `false`. It is typically necessary to **set this to
|
2489 | * `true` to successfully watch files over a network**, and it may be necessary to successfully
|
2490 | * watch files in other non-standard situations. Setting to `true` explicitly on OS X overrides
|
2491 | * the `useFsEvents` default.
|
2492 | */
|
2493 | usePolling?: boolean
|
2494 |
|
2495 | /**
|
2496 | * Whether to use the `fsevents` watching interface if available. When set to `true` explicitly
|
2497 | * and `fsevents` is available this supersedes the `usePolling` setting. When set to `false` on
|
2498 | * OS X, `usePolling: true` becomes the default.
|
2499 | */
|
2500 | useFsEvents?: boolean
|
2501 |
|
2502 | /**
|
2503 | * If relying upon the [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object that
|
2504 | * may get passed with `add`, `addDir`, and `change` events, set this to `true` to ensure it is
|
2505 | * provided even in cases where it wasn't already available from the underlying watch events.
|
2506 | */
|
2507 | alwaysStat?: boolean
|
2508 |
|
2509 | /**
|
2510 | * If set, limits how many levels of subdirectories will be traversed.
|
2511 | */
|
2512 | depth?: number
|
2513 |
|
2514 | /**
|
2515 | * Interval of file system polling.
|
2516 | */
|
2517 | interval?: number
|
2518 |
|
2519 | /**
|
2520 | * Interval of file system polling for binary files. ([see list of binary extensions](https://gi
|
2521 | * thub.com/sindresorhus/binary-extensions/blob/master/binary-extensions.json))
|
2522 | */
|
2523 | binaryInterval?: number
|
2524 |
|
2525 | /**
|
2526 | * Indicates whether to watch files that don't have read permissions if possible. If watching
|
2527 | * fails due to `EPERM` or `EACCES` with this set to `true`, the errors will be suppressed
|
2528 | * silently.
|
2529 | */
|
2530 | ignorePermissionErrors?: boolean
|
2531 |
|
2532 | /**
|
2533 | * `true` if `useFsEvents` and `usePolling` are `false`). Automatically filters out artifacts
|
2534 | * that occur when using editors that use "atomic writes" instead of writing directly to the
|
2535 | * source file. If a file is re-added within 100 ms of being deleted, Chokidar emits a `change`
|
2536 | * event rather than `unlink` then `add`. If the default of 100 ms does not work well for you,
|
2537 | * you can override it by setting `atomic` to a custom value, in milliseconds.
|
2538 | */
|
2539 | atomic?: boolean | number
|
2540 |
|
2541 | /**
|
2542 | * can be set to an object in order to adjust timing params:
|
2543 | */
|
2544 | awaitWriteFinish?:
|
2545 | | {
|
2546 | /**
|
2547 | * Amount of time in milliseconds for a file size to remain constant before emitting its event.
|
2548 | */
|
2549 | stabilityThreshold?: number
|
2550 |
|
2551 | /**
|
2552 | * File size polling interval.
|
2553 | */
|
2554 | pollInterval?: number
|
2555 | }
|
2556 | | boolean
|
2557 | }
|
2558 |
|
2559 | export declare interface WebSocketServer {
|
2560 | send(payload: HMRPayload): void;
|
2561 | close(): Promise<void>;
|
2562 | }
|
2563 |
|
2564 | export { }
|
2565 |
|
\ | No newline at end of file |