diff --git a/CHANGELOG.md b/CHANGELOG.md index e5e6f6f89805..8881cecf51e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added - Add `@tailwindcss/turbopack` package to run Tailwind CSS with Next.js ([20367](https://github.com/tailwindlabs/tailwindcss/pull/20367)) +- Enhance TypeScript `PluginOptions` types with JSDoc documentation, default tags, and examples for `@tailwindcss/vite` and `@tailwindcss/postcss` ### Fixed diff --git a/packages/@tailwindcss-postcss/src/index.ts b/packages/@tailwindcss-postcss/src/index.ts index a4a8d93268ae..961710c798d2 100644 --- a/packages/@tailwindcss-postcss/src/index.ts +++ b/packages/@tailwindcss-postcss/src/index.ts @@ -53,19 +53,54 @@ export type PluginOptions = { /** * The base directory to scan for class candidates. * - * Defaults to the current working directory. + * @default process.cwd() + * + * @example + * ```js + * export default { + * plugins: { + * '@tailwindcss/postcss': { + * base: './src', + * }, + * }, + * } + * ``` */ base?: string /** * Optimize and minify the output CSS. + * + * @default true in production, false in development + * + * @example + * ```js + * export default { + * plugins: { + * '@tailwindcss/postcss': { + * optimize: { minify: true }, + * }, + * }, + * } + * ``` */ optimize?: boolean | { minify?: boolean } /** * Enable or disable asset URL rewriting. * - * Defaults to `true`. + * @default true + * + * @example + * ```js + * export default { + * plugins: { + * '@tailwindcss/postcss': { + * transformAssetUrls: false, + * }, + * }, + * } + * ``` */ transformAssetUrls?: boolean } @@ -375,3 +410,4 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin { } export default Object.assign(tailwindcss, { postcss: true }) as PluginCreator +export { tailwindcss } diff --git a/packages/@tailwindcss-vite/README.md b/packages/@tailwindcss-vite/README.md index 1a5d25c73652..d4de5a24df7e 100644 --- a/packages/@tailwindcss-vite/README.md +++ b/packages/@tailwindcss-vite/README.md @@ -74,3 +74,21 @@ export default defineConfig({ ], }) ``` + +### TypeScript Usage + +When configuring Vite in TypeScript, `@tailwindcss/vite` provides both default and named exports, along with the `PluginOptions` type definition: + +```ts +import tailwindcss, { type PluginOptions } from '@tailwindcss/vite' +import { defineConfig } from 'vite' + +const options: PluginOptions = { + optimize: { minify: true }, +} + +export default defineConfig({ + plugins: [tailwindcss(options)], +}) +``` + diff --git a/packages/@tailwindcss-vite/src/index.ts b/packages/@tailwindcss-vite/src/index.ts index 8fc660eaac18..0824974d23b1 100644 --- a/packages/@tailwindcss-vite/src/index.ts +++ b/packages/@tailwindcss-vite/src/index.ts @@ -22,6 +22,22 @@ const INLINE_STYLE_ID_RE = /[?&]index=\d+\.css$/ export type PluginOptions = { /** * Optimize and minify the output CSS. + * + * @default true in production build, false in development + * + * @example + * ```ts + * import tailwindcss from '@tailwindcss/vite' + * import { defineConfig } from 'vite' + * + * export default defineConfig({ + * plugins: [ + * tailwindcss({ + * optimize: { minify: true }, + * }), + * ], + * }) + * ``` */ optimize?: boolean | { minify?: boolean } } @@ -541,3 +557,5 @@ class Root { return false } } + +export { tailwindcss }