1 |
|
2 |
|
3 | import Processor from 'postcss/lib/processor'
|
4 | import { Plugin, ProcessOptions, Transformer } from 'postcss'
|
5 | import { Options as ConfigOptions } from 'lilconfig'
|
6 |
|
7 | declare function postcssrc(
|
8 | ctx?: postcssrc.ConfigContext,
|
9 | path?: string,
|
10 | options?: ConfigOptions
|
11 | ): Promise<postcssrc.Result>
|
12 |
|
13 | declare namespace postcssrc {
|
14 |
|
15 |
|
16 |
|
17 | export interface ProcessOptionsPreload {
|
18 | parser?: string | ProcessOptions['parser']
|
19 | stringifier?: string | ProcessOptions['stringifier']
|
20 | syntax?: string | ProcessOptions['syntax']
|
21 | }
|
22 |
|
23 |
|
24 | export type RemainingProcessOptions = Pick<
|
25 | ProcessOptions,
|
26 | Exclude<keyof ProcessOptions, keyof ProcessOptionsPreload>
|
27 | >
|
28 |
|
29 |
|
30 | export interface Context {
|
31 | cwd?: string
|
32 | env?: string
|
33 | }
|
34 |
|
35 |
|
36 | export type ConfigContext = Context &
|
37 | ProcessOptionsPreload &
|
38 | RemainingProcessOptions
|
39 |
|
40 |
|
41 |
|
42 | export type ResultPlugin = Plugin | Transformer | Processor
|
43 |
|
44 | export interface Result {
|
45 | file: string
|
46 | options: ProcessOptions
|
47 | plugins: ResultPlugin[]
|
48 | }
|
49 |
|
50 | export type ConfigPlugin = Transformer | Plugin | Processor
|
51 |
|
52 | export interface Config {
|
53 | parser?: string | ProcessOptions['parser'] | false
|
54 | stringifier?: string | ProcessOptions['stringifier'] | false
|
55 | syntax?: string | ProcessOptions['syntax'] | false
|
56 | map?: string | false
|
57 | from?: string
|
58 | to?: string
|
59 | plugins?: Array<ConfigPlugin | false> | Record<string, object | false>
|
60 | }
|
61 |
|
62 | export type ConfigFn = (ctx: ConfigContext) => Config | Promise<Config>
|
63 | }
|
64 |
|
65 | export = postcssrc
|