fix: tailwind bg-clip-text not working (#2152)
This commit is contained in:
+11
-4
@@ -2,14 +2,21 @@ import { Plugin, PluginMiddleware, ResolvedFreshConfig } from "../server.ts";
|
|||||||
import type postcss from "npm:postcss@8.4.31";
|
import type postcss from "npm:postcss@8.4.31";
|
||||||
import * as path from "https://deno.land/std@0.207.0/path/mod.ts";
|
import * as path from "https://deno.land/std@0.207.0/path/mod.ts";
|
||||||
import { walk } from "https://deno.land/std@0.207.0/fs/walk.ts";
|
import { walk } from "https://deno.land/std@0.207.0/fs/walk.ts";
|
||||||
|
import { TailwindPluginOptions } from "./tailwind/types.ts";
|
||||||
|
|
||||||
async function initTailwind(config: ResolvedFreshConfig) {
|
async function initTailwind(
|
||||||
|
config: ResolvedFreshConfig,
|
||||||
|
options: TailwindPluginOptions,
|
||||||
|
) {
|
||||||
return await (await import("./tailwind/compiler.ts")).initTailwind(
|
return await (await import("./tailwind/compiler.ts")).initTailwind(
|
||||||
config,
|
config,
|
||||||
|
options,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function tailwind(): Plugin {
|
export default function tailwind(
|
||||||
|
options: TailwindPluginOptions = {},
|
||||||
|
): Plugin {
|
||||||
let staticDir = path.join(Deno.cwd(), "static");
|
let staticDir = path.join(Deno.cwd(), "static");
|
||||||
let processor: postcss.Processor | null = null;
|
let processor: postcss.Processor | null = null;
|
||||||
|
|
||||||
@@ -81,7 +88,7 @@ export default function tailwind(): Plugin {
|
|||||||
async configResolved(config) {
|
async configResolved(config) {
|
||||||
if (config.dev) {
|
if (config.dev) {
|
||||||
staticDir = config.staticDir;
|
staticDir = config.staticDir;
|
||||||
processor = await initTailwind(config);
|
processor = await initTailwind(config, options);
|
||||||
middlewares.push(tailwindMiddleware);
|
middlewares.push(tailwindMiddleware);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -90,7 +97,7 @@ export default function tailwind(): Plugin {
|
|||||||
staticDir = config.staticDir;
|
staticDir = config.staticDir;
|
||||||
const outDir = path.join(config.build.outDir, "static");
|
const outDir = path.join(config.build.outDir, "static");
|
||||||
|
|
||||||
processor = await initTailwind(config);
|
processor = await initTailwind(config, options);
|
||||||
|
|
||||||
const files = walk(config.staticDir, {
|
const files = walk(config.staticDir, {
|
||||||
exts: ["css"],
|
exts: ["css"],
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ import { ResolvedFreshConfig } from "../../server.ts";
|
|||||||
import tailwindCss, { Config } from "tailwindcss";
|
import tailwindCss, { Config } from "tailwindcss";
|
||||||
import postcss from "npm:postcss@8.4.31";
|
import postcss from "npm:postcss@8.4.31";
|
||||||
import cssnano from "npm:cssnano@6.0.1";
|
import cssnano from "npm:cssnano@6.0.1";
|
||||||
|
import autoprefixer from "npm:autoprefixer@10.4.16";
|
||||||
import * as path from "https://deno.land/std@0.207.0/path/mod.ts";
|
import * as path from "https://deno.land/std@0.207.0/path/mod.ts";
|
||||||
|
import { TailwindPluginOptions } from "./types.ts";
|
||||||
|
|
||||||
const CONFIG_EXTENSIONS = ["ts", "js", "mjs"];
|
const CONFIG_EXTENSIONS = ["ts", "js", "mjs"];
|
||||||
|
|
||||||
@@ -37,6 +39,7 @@ async function findTailwindConfigFile(directory: string): Promise<string> {
|
|||||||
|
|
||||||
export async function initTailwind(
|
export async function initTailwind(
|
||||||
config: ResolvedFreshConfig,
|
config: ResolvedFreshConfig,
|
||||||
|
options: TailwindPluginOptions,
|
||||||
): Promise<postcss.Processor> {
|
): Promise<postcss.Processor> {
|
||||||
const root = path.dirname(config.staticDir);
|
const root = path.dirname(config.staticDir);
|
||||||
|
|
||||||
@@ -60,9 +63,11 @@ export async function initTailwind(
|
|||||||
});
|
});
|
||||||
|
|
||||||
// PostCSS types cause deep recursion
|
// PostCSS types cause deep recursion
|
||||||
// deno-lint-ignore no-explicit-any
|
const plugins = [
|
||||||
const plugins: any[] = [
|
// deno-lint-ignore no-explicit-any
|
||||||
tailwindCss(tailwindConfig),
|
tailwindCss(tailwindConfig) as any,
|
||||||
|
// deno-lint-ignore no-explicit-any
|
||||||
|
autoprefixer(options.autoprefixer) as any,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!config.dev) {
|
if (!config.dev) {
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
export interface AutoprefixerOptions {
|
||||||
|
/** environment for `Browserslist` */
|
||||||
|
env?: string;
|
||||||
|
|
||||||
|
/** should Autoprefixer use Visual Cascade, if CSS is uncompressed */
|
||||||
|
cascade?: boolean;
|
||||||
|
|
||||||
|
/** should Autoprefixer add prefixes. */
|
||||||
|
add?: boolean;
|
||||||
|
|
||||||
|
/** should Autoprefixer [remove outdated] prefixes */
|
||||||
|
remove?: boolean;
|
||||||
|
|
||||||
|
/** should Autoprefixer add prefixes for @supports parameters. */
|
||||||
|
supports?: boolean;
|
||||||
|
|
||||||
|
/** should Autoprefixer add prefixes for flexbox properties */
|
||||||
|
flexbox?: boolean | "no-2009";
|
||||||
|
|
||||||
|
/** should Autoprefixer add IE 10-11 prefixes for Grid Layout properties */
|
||||||
|
grid?: boolean | "autoplace" | "no-autoplace";
|
||||||
|
|
||||||
|
/** custom usage statistics for > 10% in my stats browsers query */
|
||||||
|
stats?: {
|
||||||
|
[browser: string]: {
|
||||||
|
[version: string]: number;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list of queries for target browsers.
|
||||||
|
* Try to not use it.
|
||||||
|
* The best practice is to use `.browserslistrc` config or `browserslist` key in `package.json`
|
||||||
|
* to share target browsers with Babel, ESLint and Stylelint
|
||||||
|
*/
|
||||||
|
overrideBrowserslist?: string | string[];
|
||||||
|
|
||||||
|
/** do not raise error on unknown browser version in `Browserslist` config. */
|
||||||
|
ignoreUnknownVersions?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TailwindPluginOptions {
|
||||||
|
autoprefixer?: AutoprefixerOptions;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user