Prefix
This commit is contained in:
26
src/index.ts
26
src/index.ts
@ -1,11 +1,12 @@
|
||||
import hash from "@emotion/hash";
|
||||
import type { Config } from "tailwindcss";
|
||||
import type { SetRequired } from "type-fest";
|
||||
import type postcss from "postcss";
|
||||
import { memoize } from "lodash";
|
||||
import { type ClassNameCollector, babelTailwind } from "./babel-tailwind";
|
||||
import { esbuildPlugin } from "./esbuild-postcss";
|
||||
import { vitePlugin } from "./vite-plugin";
|
||||
import { type StyleMap, createPostCSS, type tailwindDirectives } from "./shared";
|
||||
import { type StyleMap, createPostCSS } from "./shared";
|
||||
|
||||
export { babelPlugin } from "./esbuild-babel";
|
||||
export { createPostCSS } from "./shared";
|
||||
@ -25,9 +26,14 @@ export interface TailwindPluginOptions {
|
||||
tailwindConfig?: Omit<Config, "content">;
|
||||
|
||||
/**
|
||||
* Directives to prefix to all Tailwind stylesheets
|
||||
* Prefix to all Tailwind stylesheets
|
||||
*
|
||||
* @example
|
||||
* tailwind base;
|
||||
* tailwind components;
|
||||
* tailwind utilities;
|
||||
*/
|
||||
directives?: (typeof tailwindDirectives)[number][] | "all" | undefined;
|
||||
prefix?: string;
|
||||
|
||||
/**
|
||||
* Additional PostCSS plugins (optional)
|
||||
@ -76,10 +82,19 @@ export interface TailwindPluginOptions {
|
||||
* @example
|
||||
* async css => (await postcss.process(css, { plugins: [tailwindcss()] })).css
|
||||
*/
|
||||
compile(css: string): Promise<string>;
|
||||
compile?(css: string): Promise<string>;
|
||||
}
|
||||
|
||||
export type ResolveTailwindOptions = Required<TailwindPluginOptions>;
|
||||
export type ResolveTailwindOptions = SetRequired<
|
||||
TailwindPluginOptions,
|
||||
| "clsx"
|
||||
| "jsxAttributeAction"
|
||||
| "jsxAttributeName"
|
||||
| "postCSSPlugins"
|
||||
| "styleMap"
|
||||
| "tailwindConfig"
|
||||
| "taggedTemplateName"
|
||||
>;
|
||||
|
||||
/**
|
||||
* Hashes and prefixes a string of Tailwind class names.
|
||||
@ -105,7 +120,6 @@ export const getClassName: GetClassName = cls => "tw-" + hash(cls);
|
||||
*/
|
||||
export function getTailwindPlugins(options: TailwindPluginOptions) {
|
||||
const resolvedOptions: ResolveTailwindOptions = {
|
||||
directives: undefined,
|
||||
getClassName,
|
||||
jsxAttributeAction: "delete",
|
||||
jsxAttributeName: "css",
|
||||
|
Reference in New Issue
Block a user