Reverts tailwind v4 update. Something is wrong with the CSS files on
fresh.deno.dev 😢
This commit is contained in:
@@ -48,11 +48,11 @@
|
||||
"@std/uuid": "jsr:@std/uuid@^1.0.7",
|
||||
"fresh": "jsr:@fresh/core@^2.0.0-alpha.29",
|
||||
"preact": "npm:preact@^10.26.6",
|
||||
"@preact/signals": "npm:@preact/signals@^2.0.4",
|
||||
"preact-render-to-string": "npm:preact-render-to-string@^6.5.11",
|
||||
"$ga4": "https://raw.githubusercontent.com/denoland/ga4/main/mod.ts",
|
||||
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.11.0",
|
||||
"@opentelemetry/api": "npm:@opentelemetry/api@^1.9.0",
|
||||
"@preact/signals": "npm:@preact/signals@^2.0.4",
|
||||
"esbuild": "npm:esbuild@0.25.4",
|
||||
"esbuild-wasm": "npm:esbuild-wasm@0.25.4",
|
||||
"@std/crypto": "jsr:@std/crypto@1",
|
||||
@@ -66,6 +66,7 @@
|
||||
"@std/path": "jsr:@std/path@1",
|
||||
"@std/semver": "jsr:@std/semver@1",
|
||||
"@std/streams": "jsr:@std/streams@1",
|
||||
|
||||
"@astral/astral": "jsr:@astral/astral@^0.5.3",
|
||||
"@marvinh-test/fresh-island": "jsr:@marvinh-test/fresh-island@^0.0.1",
|
||||
"linkedom": "npm:linkedom@^0.18.10",
|
||||
@@ -73,18 +74,19 @@
|
||||
"@std/expect": "jsr:@std/expect@^1.0.16",
|
||||
"@std/testing": "jsr:@std/testing@^1.0.12",
|
||||
|
||||
"@tailwindcss/postcss": "npm:@tailwindcss/postcss@^4.1.7",
|
||||
"@tailwindcss/oxide": "npm:@tailwindcss/oxide@^4.1.7",
|
||||
"postcss": "npm:postcss@8.5.3",
|
||||
"tailwindcss": "npm:tailwindcss@^4.1.7",
|
||||
"autoprefixer": "npm:autoprefixer@10.4.17",
|
||||
"cssnano": "npm:cssnano@6.0.3",
|
||||
"postcss": "npm:postcss@8.4.35",
|
||||
"tailwindcss": "npm:tailwindcss@^3.4.1",
|
||||
|
||||
"ts-morph": "npm:ts-morph@^25.0.1",
|
||||
"@fresh/plugin-tailwind": "./plugin-tailwindcss/src/mod.ts",
|
||||
|
||||
"@fresh/plugin-tailwind": "jsr:@fresh/plugin-tailwind@^0.0.1-alpha.7",
|
||||
"@std/front-matter": "jsr:@std/front-matter@^1.0.5",
|
||||
"fresh/compat": "./src/compat/mod.ts",
|
||||
"fresh/dev": "./src/dev/mod.ts",
|
||||
"fresh/runtime": "./src/runtime/shared.ts",
|
||||
"github-slugger": "npm:github-slugger@^2.0.0",
|
||||
"imagescript": "https://deno.land/x/imagescript@1.3.0/mod.ts",
|
||||
"marked": "npm:marked@^15.0.11",
|
||||
"marked-mangle": "npm:marked-mangle@^1.1.9",
|
||||
"prismjs": "npm:prismjs@^1.29.0"
|
||||
|
||||
+5
-3
@@ -4,7 +4,7 @@ import * as path from "@std/path";
|
||||
|
||||
// Keep these as is, as we replace these version in our release script
|
||||
const FRESH_VERSION = "2.0.0-alpha.34";
|
||||
const FRESH_TAILWIND_VERSION = "0.0.1-alpha.8";
|
||||
const FRESH_TAILWIND_VERSION = "0.0.1-alpha.7";
|
||||
const PREACT_VERSION = "10.26.6";
|
||||
const PREACT_SIGNALS_VERSION = "2.0.4";
|
||||
|
||||
@@ -338,7 +338,9 @@ html {
|
||||
${GRADIENT_CSS}`;
|
||||
|
||||
// deno-fmt-ignore
|
||||
const TAILWIND_CSS = css`@import "tailwindcss";
|
||||
const TAILWIND_CSS = css`@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
${GRADIENT_CSS}`;
|
||||
|
||||
const cssStyles = useTailwind ? TAILWIND_CSS : NO_TAILWIND_STYLES;
|
||||
@@ -549,7 +551,7 @@ if (Deno.args.includes("build")) {
|
||||
};
|
||||
|
||||
if (useTailwind) {
|
||||
denoJson.imports["tailwindcss"] = "npm:tailwindcss@^4.1.7";
|
||||
denoJson.imports["tailwindcss"] = "npm:tailwindcss@^3.4.3";
|
||||
}
|
||||
|
||||
await writeFile("deno.json", denoJson);
|
||||
|
||||
@@ -92,7 +92,7 @@ Deno.test("init - with tailwind", async () => {
|
||||
await initProject(dir, [], {});
|
||||
|
||||
const css = await readProjectFile(dir, "static/styles.css");
|
||||
expect(css).toMatch(/tailwindcss/);
|
||||
expect(css).toMatch(/@tailwind/);
|
||||
|
||||
const main = await readProjectFile(dir, "main.ts");
|
||||
const dev = await readProjectFile(dir, "dev.ts");
|
||||
|
||||
@@ -6,18 +6,22 @@ A Tailwind CSS plugin to use in Fresh.
|
||||
// dev.ts
|
||||
|
||||
import { tailwind } from "@fresh/plugin-tailwind";
|
||||
import { Builder } from "fresh/dev";
|
||||
import { FreshDevApp } from "fresh/dev";
|
||||
import { app } from "./main.ts";
|
||||
|
||||
const devApp = new Builder();
|
||||
const devApp = new FreshDevApp();
|
||||
|
||||
// Enable Tailwind CSS
|
||||
tailwind(builder, app);
|
||||
tailwind(devApp);
|
||||
|
||||
devApp.mountApp("/", app);
|
||||
|
||||
if (Deno.args.includes("build")) {
|
||||
await builder.build();
|
||||
await devApp.build({
|
||||
target: "safari12",
|
||||
});
|
||||
} else {
|
||||
await builder.listen();
|
||||
await devApp.listen();
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@fresh/plugin-tailwind",
|
||||
"version": "0.0.1-alpha.8",
|
||||
"version": "0.0.1-alpha.7",
|
||||
"license": "MIT",
|
||||
"exports": "./src/mod.ts"
|
||||
}
|
||||
|
||||
@@ -1,18 +1,80 @@
|
||||
import twPostcss from "@tailwindcss/postcss";
|
||||
import tailwindCss, { type Config } from "tailwindcss";
|
||||
import postcss from "postcss";
|
||||
import type { ResolvedFreshConfig } from "fresh";
|
||||
import autoprefixer from "autoprefixer";
|
||||
import * as path from "@std/path";
|
||||
import type { TailwindPluginOptions } from "./types.ts";
|
||||
import type { ResolvedFreshConfig } from "fresh";
|
||||
|
||||
export function initTailwind(
|
||||
const CONFIG_EXTENSIONS = ["ts", "js", "mjs"];
|
||||
|
||||
async function findTailwindConfigFile(directory: string): Promise<string> {
|
||||
let dir = directory;
|
||||
while (true) {
|
||||
for (let i = 0; i < CONFIG_EXTENSIONS.length; i++) {
|
||||
const ext = CONFIG_EXTENSIONS[i];
|
||||
const filePath = path.join(dir, `tailwind.config.${ext}`);
|
||||
try {
|
||||
const stat = await Deno.stat(filePath);
|
||||
if (stat.isFile) {
|
||||
return filePath;
|
||||
}
|
||||
} catch (err) {
|
||||
if (!(err instanceof Deno.errors.NotFound)) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const parent = path.dirname(dir);
|
||||
if (parent === dir) {
|
||||
throw new Error(
|
||||
`Could not find a tailwind config file in the current directory or any parent directory.`,
|
||||
);
|
||||
}
|
||||
|
||||
dir = parent;
|
||||
}
|
||||
}
|
||||
|
||||
export async function initTailwind(
|
||||
config: ResolvedFreshConfig,
|
||||
options: TailwindPluginOptions = {},
|
||||
): postcss.Processor {
|
||||
options: TailwindPluginOptions,
|
||||
): Promise<postcss.Processor> {
|
||||
const root = path.dirname(config.staticDir);
|
||||
|
||||
const configPath = await findTailwindConfigFile(root);
|
||||
const url = path.toFileUrl(configPath).href;
|
||||
const tailwindConfig = (await import(url)).default as Config;
|
||||
|
||||
if (!Array.isArray(tailwindConfig.content)) {
|
||||
throw new Error(`Expected tailwind "content" option to be an array`);
|
||||
}
|
||||
|
||||
// deno-lint-ignore no-explicit-any
|
||||
tailwindConfig.content = tailwindConfig.content.map((pattern: any) => {
|
||||
if (typeof pattern === "string") {
|
||||
const relative = path.relative(Deno.cwd(), path.dirname(configPath));
|
||||
|
||||
if (!relative.startsWith("..")) {
|
||||
return path.join(relative, pattern);
|
||||
}
|
||||
}
|
||||
return pattern;
|
||||
});
|
||||
|
||||
// PostCSS types cause deep recursion
|
||||
const plugins = [
|
||||
twPostcss({
|
||||
optimize: config.mode === "production",
|
||||
...options,
|
||||
}),
|
||||
// deno-lint-ignore no-explicit-any
|
||||
tailwindCss(tailwindConfig) as any,
|
||||
// deno-lint-ignore no-explicit-any
|
||||
autoprefixer(options.autoprefixer) as any,
|
||||
];
|
||||
|
||||
return postcss(plugins);
|
||||
if (config.mode === "production") {
|
||||
const { default: cssnano } = await import("cssnano");
|
||||
plugins.push(cssnano());
|
||||
}
|
||||
|
||||
const res = postcss(plugins);
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import type { TailwindPluginOptions } from "./types.ts";
|
||||
import { initTailwind } from "./compiler.ts";
|
||||
import type { FreshBuilder } from "fresh/dev";
|
||||
import type { App } from "fresh";
|
||||
import type { TailwindPluginOptions } from "./types.ts";
|
||||
|
||||
export function tailwind<T>(
|
||||
builder: FreshBuilder,
|
||||
app: App<T>,
|
||||
options: TailwindPluginOptions = {},
|
||||
): void {
|
||||
let processor: ReturnType<typeof initTailwind> | null = null;
|
||||
let processor: ReturnType<typeof initTailwind> | null;
|
||||
|
||||
builder.onTransformStaticFile(
|
||||
{ pluginName: "tailwind", filter: /\.css$/, exclude: options.exclude },
|
||||
async (args) => {
|
||||
if (!processor) processor = initTailwind(app.config);
|
||||
if (!processor) processor = initTailwind(app.config, options);
|
||||
const instance = await processor;
|
||||
const res = await instance.process(args.text, {
|
||||
from: args.path,
|
||||
|
||||
@@ -1,6 +1,48 @@
|
||||
import type { OnTransformOptions } from "@fresh/core/dev";
|
||||
|
||||
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;
|
||||
/** Exclude paths or globs that should not be processed */
|
||||
exclude?: OnTransformOptions["exclude"];
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"tasks": {
|
||||
"start": "deno run -A --allow-scripts --node-modules-dir --watch=static/,routes/,../src,../docs dev.ts",
|
||||
"start": "deno run -A --watch=static/,routes/,../src,../docs dev.ts",
|
||||
"build": "deno run -A dev.ts build",
|
||||
"preview": "deno run -A main.ts"
|
||||
}
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import { app } from "./main.ts";
|
||||
import { tailwind } from "@fresh/plugin-tailwind";
|
||||
|
||||
const builder = new Builder({ target: "safari12" });
|
||||
tailwind(builder, app);
|
||||
tailwind(builder, app, {});
|
||||
|
||||
if (Deno.args.includes("build")) {
|
||||
await builder.build(app);
|
||||
|
||||
+24
-24
@@ -1,33 +1,35 @@
|
||||
@import "tailwindcss";
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
||||
/* Light and dark theme variables */
|
||||
:root {
|
||||
--fresh: hsla(50, 100%, 56%, 1);
|
||||
--fresh-green: hsla(142, 71%, 29%, 1);
|
||||
--fresh: 50deg, 100%, 56%;
|
||||
--fresh-green: 142deg, 71%, 29%;
|
||||
|
||||
--background-primary: 215deg, 100%, 100%;
|
||||
--background-secondary: hsla(210, 29%, 97%, 1);
|
||||
--background-tertiary: hsla(207, 33%, 95%, 1);
|
||||
--foreground-primary: hsla(0, 0%, 9%, 1);
|
||||
--foreground-secondary: hsla(0, 0%, 23%, 1);
|
||||
--foreground-tertiary: hsla(0, 0%, 32%, 1);
|
||||
--foreground-quaternary: hsla(0, 0%, 42%, 1);
|
||||
--background-secondary: 210deg, 29%, 97%;
|
||||
--background-tertiary: 207deg, 33%, 95%;
|
||||
--foreground-primary: 0deg, 0%, 9%;
|
||||
--foreground-secondary: 0deg, 0%, 23%;
|
||||
--foreground-tertiary: 0deg, 0%, 32%;
|
||||
--foreground-quaternary: 0deg, 0%, 42%;
|
||||
|
||||
--info: hsla(194, 76%, 41%, 1);
|
||||
--info: 194deg, 76%, 41%;
|
||||
}
|
||||
html[data-theme="dark"]:root {
|
||||
--fresh: hsla(50, 100%, 56%, 1);
|
||||
--fresh-green: hsla(142, 71%, 29%, 1);
|
||||
--fresh: 50deg, 100%, 56%;
|
||||
--fresh-green: 142deg, 71%, 29%;
|
||||
|
||||
--background-primary: hsla(216, 27.8%, 7.1%, 1);
|
||||
--background-secondary: hsla(216, 27.7%, 12%, 1);
|
||||
--background-tertiary: hsla(216, 27.7%, 22%, 1);
|
||||
--foreground-primary: hsla(215, 17%, 99%, 1);
|
||||
--foreground-secondary: hsla(215, 17%, 71%, 1);
|
||||
--foreground-tertiary: hsla(215, 17%, 20%, 1);
|
||||
--foreground-quaternary: hsla(215, 17%, 10%, 1);
|
||||
--background-primary: 216deg, 27.8%, 7.1%;
|
||||
--background-secondary: 216deg, 27.7%, 12%;
|
||||
--background-tertiary: 216deg, 27.7%, 22%;
|
||||
--foreground-primary: 215deg, 17%, 99%;
|
||||
--foreground-secondary: 215deg, 17%, 71%;
|
||||
--foreground-tertiary: 215deg, 17%, 20%;
|
||||
--foreground-quaternary: 215deg, 17%, 10%;
|
||||
|
||||
--info: hsla(194, 76%, 41%, 1);
|
||||
--info: 194deg, 76%, 41%;
|
||||
|
||||
color: var(--foreground-primary);
|
||||
background-color: var(--background-primary);
|
||||
@@ -96,13 +98,11 @@ h6 {
|
||||
}
|
||||
|
||||
hr {
|
||||
/* @apply border-foreground-secondary/10; */
|
||||
border-color: hsla(var(--foreground-secondary), 0.1);
|
||||
@apply border-foreground-secondary/10;
|
||||
}
|
||||
|
||||
.dark-mode-toggle-button img {
|
||||
/* @apply fill-foreground-primary; */
|
||||
fill: var(--foreground-primary);
|
||||
@apply fill-foreground-primary;
|
||||
}
|
||||
|
||||
::selection {
|
||||
|
||||
+11
-18
@@ -21,26 +21,19 @@ export default {
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
// use RGB variables with alpha value
|
||||
"fresh": "rgb(var(--fresh-rgb) / <alpha-value>)",
|
||||
"fresh-green": "rgb(var(--fresh-green-rgb) / <alpha-value>)",
|
||||
// Dark/light with Tailwind done right using CSS variables:
|
||||
"fresh": "hsla(var(--fresh))",
|
||||
"fresh-green": "hsla(var(--fresh-green))",
|
||||
|
||||
"background-primary":
|
||||
"rgb(var(--background-primary-rgb) / <alpha-value>)",
|
||||
"background-secondary":
|
||||
"rgb(var(--background-secondary-rgb) / <alpha-value>)",
|
||||
"background-tertiary":
|
||||
"rgb(var(--background-tertiary-rgb) / <alpha-value>)",
|
||||
"foreground-primary":
|
||||
"rgb(var(--foreground-primary-rgb) / <alpha-value>)",
|
||||
"foreground-secondary":
|
||||
"rgb(var(--foreground-secondary-rgb) / <alpha-value>)",
|
||||
"foreground-tertiary":
|
||||
"rgb(var(--foreground-tertiary-rgb) / <alpha-value>)",
|
||||
"foreground-quaternary":
|
||||
"rgb(var(--foreground-quaternary-rgb) / <alpha-value>)",
|
||||
"background-primary": "hsla(var(--background-primary))",
|
||||
"background-secondary": "hsla(var(--background-secondary))",
|
||||
"background-tertiary": "hsla(var(--background-tertiary))",
|
||||
"foreground-primary": "hsla(var(--foreground-primary))",
|
||||
"foreground-secondary": "hsla(var(--foreground-secondary))",
|
||||
"foreground-tertiary": "hsla(var(--foreground-tertiary))",
|
||||
"foreground-quaternary": "hsla(var(--foreground-quaternary))",
|
||||
|
||||
"info": "rgb(var(--info-rgb) / <alpha-value>)",
|
||||
"info": "hsla(var(--info))",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user