Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for TypeScript based configs #632

Merged
merged 8 commits into from
Apr 3, 2023
Merged
35 changes: 18 additions & 17 deletions README.md
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you were hoping to see by updating the docs? @alexander-akait

Original file line number Diff line number Diff line change
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