feat(core): support exclude option for transformers (#2960)
This PR adds general support for an `exclude` option to file transformers. This allows plugin to skip processing excluded files. The exclude array can be a `string`, a `RegExp` or a glob pattern. Fixes https://github.com/denoland/fresh/issues/2937
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
import type { TailwindPluginOptions } from "./types.ts";
|
||||
import { initTailwind } from "./compiler.ts";
|
||||
import type { Builder } from "fresh/dev";
|
||||
import type { FreshBuilder } from "fresh/dev";
|
||||
import type { App } from "fresh";
|
||||
|
||||
export function tailwind<T>(
|
||||
builder: Builder,
|
||||
builder: FreshBuilder,
|
||||
app: App<T>,
|
||||
options: TailwindPluginOptions = {},
|
||||
): void {
|
||||
let processor: ReturnType<typeof initTailwind> | null;
|
||||
|
||||
builder.onTransformStaticFile(
|
||||
{ pluginName: "tailwind", filter: /\.css$/ },
|
||||
{ pluginName: "tailwind", filter: /\.css$/, exclude: options.exclude },
|
||||
async (args) => {
|
||||
if (!processor) processor = initTailwind(app.config, options);
|
||||
const instance = await processor;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { OnTransformOptions } from "@fresh/core/dev";
|
||||
|
||||
export interface AutoprefixerOptions {
|
||||
/** environment for `Browserslist` */
|
||||
env?: string;
|
||||
@@ -41,4 +43,6 @@ export interface AutoprefixerOptions {
|
||||
|
||||
export interface TailwindPluginOptions {
|
||||
autoprefixer?: AutoprefixerOptions;
|
||||
/** Exclude paths or globs that should not be processed */
|
||||
exclude?: OnTransformOptions["exclude"];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user