-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move tailwind plugin into its own folder
- Loading branch information
1 parent
c8304ab
commit 6c23ef4
Showing
8 changed files
with
50 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,14 +40,12 @@ | |
"$std/": "https://deno.land/[email protected]/", | ||
"@fresh/core": "./src/mod.ts", | ||
"@fresh/core/dev": "./src/dev/mod.ts", | ||
"@fresh/plugin-tailwind": "./src/plugins/tailwind/mod.ts", | ||
"@fresh/plugin-tailwind": "./plugin-tailwindcss/src/mod.ts", | ||
"@fresh/runtime": "./src/runtime/mod.ts", | ||
"@fresh/server": "./src/mod.ts", | ||
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3", | ||
"preact": "https://esm.sh/[email protected]", | ||
"preact/": "https://esm.sh/[email protected]/", | ||
"preact-render-to-string": "https://esm.sh/[email protected]?external=preact", | ||
"@preact/signals": "https://esm.sh/@preact/[email protected]?external=preact", | ||
"@std/cli": "jsr:@std/cli@^0.220.1", | ||
"@std/crypto": "jsr:@std/crypto@^0.220.1", | ||
"@std/encoding": "jsr:@std/encoding@^0.220.1", | ||
"@std/expect": "jsr:@std/expect@^0.220.1", | ||
|
@@ -56,12 +54,18 @@ | |
"@std/jsonc": "jsr:@std/jsonc@^0.220.1", | ||
"@std/media-types": "jsr:@std/media-types@^0.220.1", | ||
"@std/path": "jsr:@std/path@^0.220.1", | ||
"esbuild": "npm:[email protected]", | ||
"esbuild-wasm": "npm:[email protected]", | ||
"preact": "https://esm.sh/[email protected]", | ||
"preact-render-to-string": "https://esm.sh/[email protected]?external=preact", | ||
"preact/": "https://esm.sh/[email protected]/", | ||
"tailwindcss": "npm:tailwindcss@^3.4.1", | ||
"tailwindcss/plugin": "npm:/tailwindcss@^3.4.1/plugin.js", | ||
"esbuild-wasm": "npm:[email protected]", | ||
"esbuild": "npm:[email protected]", | ||
"twind": "https://esm.sh/[email protected]", | ||
"twind/": "https://esm.sh/[email protected]/" | ||
"twind/": "https://esm.sh/[email protected]/", | ||
"postcss": "npm:[email protected]", | ||
"cssnano": "npm:[email protected]", | ||
"autoprefixer": "npm:[email protected]" | ||
}, | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -364,7 +364,7 @@ if (import.meta.main) { | |
await writeProjectFile("main.ts", MAIN_TS); | ||
|
||
const DEV_TS = `#!/usr/bin/env -S deno run -A --watch=static/,routes/ | ||
import { tailwind } from "@fresh/plugin-tailwind"; | ||
${useTailwind ? `import { tailwind } from "@fresh/plugin-tailwind";\n` : ""}; | ||
import { FreshDevApp } from "@fresh/core/dev"; | ||
import { app } from "./main.ts"; | ||
|
@@ -398,15 +398,21 @@ const denoJson = { | |
imports: { | ||
// FIXME: Update once relased | ||
"@fresh/core": "jsr:@marvinh-test/fresh@^2.0.0-prealpha.8", | ||
"@fresh/plugin-tailwind": "jsr:@marvinh-test/fresh@^2.0.0-prealpha.8", | ||
"preact": "npm:preact@^10.20.1", | ||
"preact/signals": "npm:preact@^1.2.3", | ||
}, | ||
} as Record<string, string>, | ||
compilerOptions: { | ||
jsx: "react-jsx", | ||
jsxImportSource: "preact", | ||
}, | ||
}; | ||
|
||
if (useTailwind) { | ||
denoJson.imports["tailwindcss"] = "npm:[email protected]"; | ||
denoJson.imports["tailwindcss/plugin"] = "npm:[email protected]/plugin.js"; | ||
} | ||
|
||
await writeProjectFile("deno.json", denoJson); | ||
|
||
const README_MD = `# Fresh project | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "@marvinh-test/fresh-tailwind", | ||
"version": "0.0.1", | ||
"exports": { | ||
".": "./src/mod.ts" | ||
}, | ||
"imports": { | ||
"@fresh/core": "jsr:@marvinh-test/fresh@^2.0.0-prealpha.0", | ||
"@std/path": "jsr:@std/path@^0.220.1", | ||
"autoprefixer": "npm:[email protected]", | ||
"cssnano": "npm:[email protected]", | ||
"postcss": "npm:[email protected]", | ||
"tailwindcss": "npm:tailwindcss@^3.4.1" | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
src/plugins/tailwind/compiler.ts → plugin-tailwindcss/src/compiler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 4 additions & 7 deletions
11
src/plugins/tailwind/mod.ts → plugin-tailwindcss/src/mod.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,16 @@ | ||
import { TailwindPluginOptions } from "./types.ts"; | ||
import { initTailwind } from "./compiler.ts"; | ||
import { DevApp } from "../../dev/dev_app.ts"; | ||
import { Processor } from "npm:[email protected]"; | ||
import { DevApp } from "@fresh/core/dev"; | ||
|
||
export function tailwind<T>( | ||
app: DevApp<T>, | ||
options: TailwindPluginOptions = {}, | ||
): void { | ||
let processor: Processor | null = null; | ||
const processor = initTailwind(app.config, options); | ||
|
||
app.onTransformStaticFile({ filter: /\.css$/ }, async (args) => { | ||
if (processor === null) { | ||
processor = await initTailwind(app.config, options); | ||
} | ||
const res = await processor.process(args.text, { | ||
const instance = await processor; | ||
const res = await instance.process(args.text, { | ||
from: args.path, | ||
}); | ||
|
||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,17 @@ | |
"@fresh/core/dev": "../src/dev/mod.ts", | ||
"@fresh/server": "../src/mod.ts", | ||
"@fresh/runtime": "../src/runtime/client/mod.tsx", | ||
"@fresh/plugin-tailwind": "../src/plugins/tailwind/mod.ts", | ||
"@fresh/plugin-tailwind": "../plugin-tailwindcss/src/mod.ts", | ||
"@std/crypto": "jsr:@std/crypto", | ||
"@std/path": "jsr:@std/path", | ||
"@std/encoding": "jsr:@std/encoding", | ||
"@std/media-types": "jsr:@std/media-types@^0.220.1", | ||
"@std/fmt": "jsr:@std/fmt", | ||
"@std/fs": "jsr:@std/fs", | ||
"@std/jsonc": "jsr:@std/jsonc@^0.220.1", | ||
"autoprefixer": "npm:[email protected]", | ||
"cssnano": "npm:[email protected]", | ||
"postcss": "npm:[email protected]", | ||
"@luca/esbuild-deno-loader": "jsr:@luca/esbuild-deno-loader@^0.10.3", | ||
"preact": "https://esm.sh/[email protected]", | ||
"preact/": "https://esm.sh/[email protected]/", | ||
|