diff options
author | 2021-04-14 10:36:00 -0600 | |
---|---|---|
committer | 2021-04-14 10:36:00 -0600 | |
commit | ec75312a153424a47e05d72d41f4c3152cc7ad09 (patch) | |
tree | 147f4938689b79ff6731f3a65a82a99aa81bfec5 /src | |
parent | 3d0d53486caa1c6194aa0cdc0f3988824462bca4 (diff) | |
download | astro-ec75312a153424a47e05d72d41f4c3152cc7ad09.tar.gz astro-ec75312a153424a47e05d72d41f4c3152cc7ad09.tar.zst astro-ec75312a153424a47e05d72d41f4c3152cc7ad09.zip |
Improve Tailwind docs & Tailwind support (#92)
Diffstat (limited to 'src')
-rw-r--r-- | src/@types/tailwind.d.ts | 1 | ||||
-rw-r--r-- | src/compiler/transform/styles.ts | 6 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/@types/tailwind.d.ts b/src/@types/tailwind.d.ts index 99ae97419..d25eaae2f 100644 --- a/src/@types/tailwind.d.ts +++ b/src/@types/tailwind.d.ts @@ -1,3 +1,2 @@ // we shouldnât have this as a dependency for Astro, but we may dynamically import it if a user requests it, so let TS know about it declare module 'tailwindcss'; -declare module '@tailwindcss/jit'; diff --git a/src/compiler/transform/styles.ts b/src/compiler/transform/styles.ts index 0c7b4c3c1..bb07f3267 100644 --- a/src/compiler/transform/styles.ts +++ b/src/compiler/transform/styles.ts @@ -1,5 +1,6 @@ import crypto from 'crypto'; import fs from 'fs'; +import { createRequire } from 'module'; import path from 'path'; import autoprefixer from 'autoprefixer'; import postcss, { Plugin } from 'postcss'; @@ -121,8 +122,9 @@ async function transformStyle(code: string, { type, filename, scopedClass, mode // 2a. Tailwind (only if project uses Tailwind) if (miniCache.tailwindEnabled) { try { - const { default: tailwindcss } = await import('@tailwindcss/jit'); - postcssPlugins.push(tailwindcss()); + const require = createRequire(import.meta.url); + const tw = require.resolve('tailwindcss', { paths: [import.meta.url, process.cwd()] }); + postcssPlugins.push(require(tw) as any); } catch (err) { // eslint-disable-next-line no-console console.error(err); |