fix postcss warning with from
This commit is contained in:
@@ -5,17 +5,20 @@ import type { Result } from "postcss"
|
|||||||
import postcss from "postcss"
|
import postcss from "postcss"
|
||||||
import tailwindcss from "tailwindcss"
|
import tailwindcss from "tailwindcss"
|
||||||
|
|
||||||
const tailwindTemplate = await readFile(
|
const tailwindTemplatePath = fileURLToPath(
|
||||||
fileURLToPath(await import.meta.resolve!("tailwindcss/tailwind.css")),
|
await import.meta.resolve!("tailwindcss/tailwind.css"),
|
||||||
"utf-8",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const tailwindTemplate = await readFile(tailwindTemplatePath, "utf-8")
|
||||||
|
|
||||||
let result: Result | undefined
|
let result: Result | undefined
|
||||||
|
|
||||||
export function serveTailwindCss(): RequestHandler {
|
export function serveTailwindCss(): RequestHandler {
|
||||||
return async (req, res) => {
|
return async (req, res) => {
|
||||||
if (!result || process.env.NODE_ENV !== "production") {
|
if (!result || process.env.NODE_ENV !== "production") {
|
||||||
result = await postcss(tailwindcss).process(tailwindTemplate)
|
result = await postcss(tailwindcss).process(tailwindTemplate, {
|
||||||
|
from: tailwindTemplatePath,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
res.set("Content-Type", "text/css").send(result.css)
|
res.set("Content-Type", "text/css").send(result.css)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user