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
@@ -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