-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Twind completions in Fresh (Deno) workspace not autocompleting custom theme #18
Comments
it looks like it's a duplicate of: #10 |
i have read all of doc of twind for adding font from 'import' and 'font-face' it still doesn't work :( |
It works when removing the selfURL property. |
I think it has something to do with |
unfortunately still can't get it to work with the fix you mentioned above: Have also restarted both Twind Intellisense and Deno lsp. |
You cannot import |
Try changing it to /** @type {import("$fresh").Options} */ Right above the export, so it avoids the import entirely. |
Change it to: /** @type {Omit<import("$fresh/plugins/twind.ts").Options, "selfURL">} */
export default {
// ... |
May you could just trying remove fresh's import like Hope this comment can help you 😄. |
Thanks @mooxl for showing your solution. Could you also shown your twind.config.ts file? I'm using
This is my main.ts: /// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "@/fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twind.ts";
import twindConfig from "@/twind.config.ts";
await start(manifest, {
plugins: [
twindPlugin({
selfURL: new URL("./twind.config.ts", import.meta.url).href,
preflight: {},
...twindConfig,
}),
],
}); twind.config.ts: import { Options } from "$fresh/plugins/twind.ts";
import * as colors from "twind/colors";
export default {
// selfURL: import.meta.url,
darkMode: "class",
mode: "silent",
theme: {
extend: {
colors,
},
},
} as unknown as Options; I got this error in my main.ts: The |
Hey, @gmunumel, the error means your Move twindPlugin({
preflight: {},
...twindConfig,
selfURL: new URL("./twind.config.ts", import.meta.url).href,
}); Or you can change the twindConfig's type assert to To fix the second error ( |
As @JuerGenie mentioned, you get an error because the typing is not right. main.ts /// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
import { apply } from "twind";
import twindPlugin from "$fresh/plugins/twind.ts";
import twindConfig from "./twind.config.ts";
await start(manifest, {
plugins: [
twindPlugin({
selfURL: new URL("./twind.config.ts", import.meta.url).href,
preflight: {
"@font-face": [
{
fontFamily: "Plex",
src: 'url(/fonts/Plex-Regular.woff2) format("woff2")',
},
{
fontFamily: "Plex",
fontWeight: "bold",
src: 'url(/fonts/Plex-Bold.woff2) format("woff2")',
},
],
html: apply`text-html bg-gray`,
body: apply`text-sm text-white font-plex leading-none tracking-wide`,
},
...twindConfig,
}),
],
}); twind.config.ts import { Options } from "$fresh/plugins/twind.ts";
export default {
theme: {
fontSize: {
html: "62.5%",
sm: "1.6rem",
md: "2.1rem",
lg: "3rem",
xl: "5rem",
},
fontWeight: {
bold: "700",
},
screens: {
lg: { max: "1040px" },
md: { max: "768px" },
sm: { max: "640px" },
},
fontFamily: {
plex: ["Plex", "sans-serif"],
},
maxWidth: {
xl: "1000px",
experience: "550px",
},
extend: {
colors: {
gray: {
DEFAULT: "#111111",
light: "#888888",
dark: "#222222",
},
},
gridTemplateColumns: {
desktop: "min-content auto",
},
},
},
} as Pick<Options, "theme">; With this structure i get no linting and typing errors and the intellisense from Twind works:) @gmunumel |
Thanks @JuerGenie and @mooxl, for your suggestions. Indeed the lint errors are gone. I only have the error with the custom css: I tried to do the following with no luck (I'm using main.ts: /// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "@/fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twind.ts";
// import twindConfig from "@/twind.config.ts";
import * as colors from "twind/colors";
await start(manifest, {
plugins: [
twindPlugin({
selfURL: new URL("./twind.config.ts", import.meta.url).href,
preflight: {},
// ...twindConfig,
darkMode: "class",
// mode: "silent",
theme: {
extend: {
colors,
},
},
}),
],
}); import_map.json: {
"imports": {
"@/": "./",
"$fresh/": "https://deno.land/x/fresh@1.1.1/",
"preact": "https://esm.sh/preact@10.11.0",
"preact/": "https://esm.sh/preact@10.11.0/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@5.2.4",
"@preact/signals": "https://esm.sh/*@preact/signals@1.0.3",
"@preact/signals-core": "https://esm.sh/*@preact/signals-core@1.0.1",
"twind": "https://esm.sh/twind@0.16.17",
"twind/": "https://esm.sh/twind@0.16.17/",
"dotenv": "https://deno.land/x/dotenv@v3.2.0/load.ts",
"$std/": "https://deno.land/std@0.151.0/",
"statery": "https://esm.sh/statery@0.5.4?alias=react:preact/compat&deps=preact@10.8.2",
"jwt": "https://deno.land/x/djwt@v2.7/mod.ts"
}
}
I don't want to hijack this topic. May I open another ticket if you want to ;) |
You have to define your theme in |
Nop. Doesn't work for me. Still get the same error in my index.tsx. main.ts: /// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "@/fresh.gen.ts";
import twindPlugin from "$fresh/plugins/twind.ts";
import twindConfig from "@/twind.config.ts";
await start(manifest, {
plugins: [
twindPlugin({
selfURL: new URL("./twind.config.ts", import.meta.url).href,
preflight: {},
...twindConfig,
}),
],
}); twind.config.ts: // import { Options } from "$fresh/plugins/twind.ts";
import * as colors from "twind/colors";
export default {
// selfURL: import.meta.url,
darkMode: "class",
mode: "silent",
theme: {
extend: {
colors,
},
},
// deno-lint-ignore no-explicit-any
} as Pick<any, "theme">; |
It's ok, I'm using Deno too, but extension with VSCode was running on electron (based on NodeJS), so you know :D |
Workaround -> #10 (comment) This will let you use the official tailwind extension instead |
twind config
Logs:
The text was updated successfully, but these errors were encountered: