Skip to content

Commit c6b5def

Browse files
authored
feat: add support for TypeScript based configs (#632)
1 parent ff6d955 commit c6b5def

File tree

14 files changed

+1764
-14619
lines changed

14 files changed

+1764
-14619
lines changed

README.md

+18-17
Original file line numberDiff line numberDiff line change
@@ -190,26 +190,27 @@ module.exports = {
190190

191191
### `postcssOptions`
192192

193+
See the file [`./src/config.d.ts`](./src/config.d.ts).
194+
193195
Type:
194196

195197
```ts
196-
type postcssOptions =
197-
| {
198-
from: string;
199-
map: boolean | SourceMapOptions;
200-
parser: string | object | (() => Parser);
201-
stringifier: Stringifier | Syntax;
202-
syntax: Syntax;
203-
to: string;
204-
}
205-
| ((loaderContext: LoaderContext) => {
206-
from: string;
207-
map: boolean | SourceMapOptions;
208-
parser: string | object | (() => Parser);
209-
stringifier: Stringifier | Syntax;
210-
syntax: Syntax;
211-
to: string;
212-
});
198+
import type { Config as PostCSSConfig } from "postcss-load-config";
199+
import type { LoaderContext } from "webpack";
200+
201+
type PostCSSLoaderContext = LoaderContext<PostCSSConfig>;
202+
203+
interface PostCSSLoaderAPI {
204+
mode: PostCSSLoaderContext["mode"];
205+
file: PostCSSLoaderContext["resourcePath"];
206+
webpackLoaderContext: PostCSSLoaderContext;
207+
env: PostCSSLoaderContext["mode"];
208+
options: PostCSSConfig;
209+
}
210+
211+
export type PostCSSLoaderOptions =
212+
| PostCSSConfig
213+
| ((api: PostCSSLoaderAPI) => PostCSSConfig);
213214
```
214215

215216
Default: `undefined`

0 commit comments

Comments
 (0)