Skip to content

Commit

Permalink
feat: add support for TypeScript based configs (#632)
Browse files Browse the repository at this point in the history
  • Loading branch information
xeho91 committed Apr 3, 2023
1 parent ff6d955 commit c6b5def
Show file tree
Hide file tree
Showing 14 changed files with 1,764 additions and 14,619 deletions.
35 changes: 18 additions & 17 deletions README.md
Expand Up @@ -190,26 +190,27 @@ module.exports = {

### `postcssOptions`

See the file [`./src/config.d.ts`](./src/config.d.ts).

Type:

```ts
type postcssOptions =
| {
from: string;
map: boolean | SourceMapOptions;
parser: string | object | (() => Parser);
stringifier: Stringifier | Syntax;
syntax: Syntax;
to: string;
}
| ((loaderContext: LoaderContext) => {
from: string;
map: boolean | SourceMapOptions;
parser: string | object | (() => Parser);
stringifier: Stringifier | Syntax;
syntax: Syntax;
to: string;
});
import type { Config as PostCSSConfig } from "postcss-load-config";
import type { LoaderContext } from "webpack";

type PostCSSLoaderContext = LoaderContext<PostCSSConfig>;

interface PostCSSLoaderAPI {
mode: PostCSSLoaderContext["mode"];
file: PostCSSLoaderContext["resourcePath"];
webpackLoaderContext: PostCSSLoaderContext;
env: PostCSSLoaderContext["mode"];
options: PostCSSConfig;
}

export type PostCSSLoaderOptions =
| PostCSSConfig
| ((api: PostCSSLoaderAPI) => PostCSSConfig);
```

Default: `undefined`
Expand Down

0 comments on commit c6b5def

Please sign in to comment.