diff --git a/plugins/tailwind/bundler.ts b/plugins/tailwind/bundler.ts index 2004a20..54b0ab2 100644 --- a/plugins/tailwind/bundler.ts +++ b/plugins/tailwind/bundler.ts @@ -52,7 +52,7 @@ export const bundle = async ( ); console.info( - ` 🎨 Tailwind css ready in ${ + ` 🎨 TailwindCSS ready in ${ cyan(`${((performance.now() - start) / 1e3).toFixed(1)}s`) }`, ); diff --git a/plugins/tailwind/deno.ts b/plugins/tailwind/deno.ts index a996dd1..bdf43b2 100644 --- a/plugins/tailwind/deno.ts +++ b/plugins/tailwind/deno.ts @@ -24,10 +24,7 @@ const visit = ( } }; -const importsFrom = async ( - path: string, - verbose: boolean, -): Promise => { +const importsFrom = async (path: string): Promise => { const program = await parsePath(path); if (!program) { @@ -59,21 +56,6 @@ const importsFrom = async ( const arg0 = node.arguments?.[0]?.expression; if (arg0.type !== "StringLiteral") { - if (path.endsWith(".tsx") && verbose) { - console.warn([ - `Invalid import statement`, - `TailwindCSS will not load classes from dependencies of ${path}`, - "To fix this issue, make sure you are following the patterns:", - ` Statically evaluated imports WORK`, - ` import("path/to/file")`, - ` lazy(() => import("path/to/file"))`, - ` Dinamically evaluated imports FAIL`, - ` import(\`path/to/file\`)`, - ` lazy((variable) => import(\`path/to/file/\${variable}\`))`, - "", - ].join("\n")); - } - return; } @@ -107,7 +89,6 @@ const resolveRecursively = async ( loader: (specifier: string) => Promise, importMapResolver: ImportMapResolver, cache: Map, - verbose: boolean, ) => { const resolvedPath = importMapResolver.resolve(path, context); @@ -117,7 +98,7 @@ const resolveRecursively = async ( const [content, imports] = await Promise.all([ loader(resolvedPath), - importsFrom(resolvedPath, verbose), + importsFrom(resolvedPath), ]); if (!content) { @@ -126,10 +107,6 @@ const resolveRecursively = async ( cache.set(resolvedPath, content); - if (verbose) { - console.log(`TailwindCSS plugin is resolving: [${imports.join(", ")}]`); - } - await Promise.all(imports.map((imp) => resolveRecursively( imp, @@ -137,7 +114,6 @@ const resolveRecursively = async ( loader, importMapResolver, cache, - verbose, ) )); }; @@ -163,7 +139,6 @@ const readImportMap = async () => { export const resolveDeps = async ( entries: string[], cache: Map, - verbose = false, ) => { const importMap = await readImportMap(); const loader = initLoader(); @@ -180,7 +155,6 @@ export const resolveDeps = async ( loader, importMapResolver, cache, - verbose, ); } }; diff --git a/plugins/tailwind/mod.ts b/plugins/tailwind/mod.ts index 259df75..4be9775 100644 --- a/plugins/tailwind/mod.ts +++ b/plugins/tailwind/mod.ts @@ -97,7 +97,8 @@ export const plugin = (config?: Config & { verbose?: boolean }): Plugin => { name: "deco-tailwind", routes, configResolved: async (fresh) => { - const mode = fresh.dev ? "dev" : "prod"; + const isDev = fresh.dev || Deno.env.get("DECO_PREVIEW"); + const mode = isDev ? "dev" : "prod"; const ctx = Context.active(); const withReleaseContent = async (config: Config) => { @@ -117,7 +118,13 @@ export const plugin = (config?: Config & { verbose?: boolean }): Plugin => { } } - await resolveDeps([...roots.values()], allTsxFiles, config.verbose); + const start = performance.now(); + await resolveDeps([...roots.values()], allTsxFiles); + const duration = (performance.now() - start).toFixed(0); + + console.log( + ` 🔍 TailwindCSS resolved ${allTsxFiles.size} dependencies in ${duration}ms`, + ); return { ...config,