feat: support fresh projects that are part of a workspace (#2716)
Also a performance improvement & bug fix in the tailwind plugin. --------- Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
co-authored by
Marvin Hagemeister
parent
bf43a0e90c
commit
407987589f
@@ -6,8 +6,8 @@
|
||||
".": "./src/mod.ts"
|
||||
},
|
||||
"imports": {
|
||||
"fresh": "jsr:@fresh/core@^2.0.0-alpha.1",
|
||||
"@std/path": "jsr:@std/path@^0.221.0",
|
||||
"fresh": "jsr:@fresh/core@^2.0.0-alpha.22",
|
||||
"@std/path": "jsr:@std/path@1",
|
||||
"autoprefixer": "npm:autoprefixer@10.4.17",
|
||||
"cssnano": "npm:cssnano@6.0.3",
|
||||
"postcss": "npm:postcss@8.4.35",
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import tailwindCss, { type Config } from "tailwindcss";
|
||||
import postcss from "postcss";
|
||||
import cssnano from "cssnano";
|
||||
import autoprefixer from "autoprefixer";
|
||||
import * as path from "@std/path";
|
||||
import type { TailwindPluginOptions } from "./types.ts";
|
||||
@@ -72,8 +71,10 @@ export async function initTailwind(
|
||||
];
|
||||
|
||||
if (config.mode === "production") {
|
||||
const { default: cssnano } = await import("cssnano");
|
||||
plugins.push(cssnano());
|
||||
}
|
||||
|
||||
return postcss(plugins);
|
||||
const res = postcss(plugins);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,12 @@ export function tailwind<T>(
|
||||
app: App<T>,
|
||||
options: TailwindPluginOptions = {},
|
||||
): void {
|
||||
const processor = initTailwind(app.config, options);
|
||||
let processor: ReturnType<typeof initTailwind> | null;
|
||||
|
||||
builder.onTransformStaticFile(
|
||||
{ pluginName: "tailwind", filter: /\.css$/ },
|
||||
async (args) => {
|
||||
if (!processor) processor = initTailwind(app.config, options);
|
||||
const instance = await processor;
|
||||
const res = await instance.process(args.text, {
|
||||
from: args.path,
|
||||
|
||||
Reference in New Issue
Block a user