summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Brad Cornes <bradlc41@gmail.com> 2021-06-16 18:36:19 +0100
committerGravatar GitHub <noreply@github.com> 2021-06-16 11:36:19 -0600
commit3ada25d7d9ebbdff469d31399ac112d3d7fb7249 (patch)
treea65bb6c24a5fd5233204fd9e4467112713adc437
parentc0804fc8cd10b1f8bec6c3784cde9623fb871062 (diff)
downloadastro-3ada25d7d9ebbdff469d31399ac112d3d7fb7249.tar.gz
astro-3ada25d7d9ebbdff469d31399ac112d3d7fb7249.tar.zst
astro-3ada25d7d9ebbdff469d31399ac112d3d7fb7249.zip
Pass configured Tailwind config file to the `tailwindcss` plugin (#352)
* fix tailwind config filename * pass configured config file to tailwindcss * add changeset * remove `tailwindConfig` from `CompileOptions` interface
-rw-r--r--.changeset/breezy-parrots-bathe.md5
-rw-r--r--docs/styling.md2
-rw-r--r--packages/astro/src/@types/compiler.ts1
-rw-r--r--packages/astro/src/compiler/transform/styles.ts4
-rw-r--r--packages/astro/src/runtime.ts2
5 files changed, 9 insertions, 5 deletions
diff --git a/.changeset/breezy-parrots-bathe.md b/.changeset/breezy-parrots-bathe.md
new file mode 100644
index 000000000..99b250914
--- /dev/null
+++ b/.changeset/breezy-parrots-bathe.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Pass configured Tailwind config file to the tailwindcss plugin
diff --git a/docs/styling.md b/docs/styling.md
index 2f57cd21f..86ce2e840 100644
--- a/docs/styling.md
+++ b/docs/styling.md
@@ -107,7 +107,7 @@ Be sure to add the config path to `astro.config.mjs`, so that Astro enables JIT
// astro.config.mjs
export default {
+ devOptions: {
-+ tailwindConfig: './tailwindConfig.js',
++ tailwindConfig: './tailwind.config.js',
+ },
};
```
diff --git a/packages/astro/src/@types/compiler.ts b/packages/astro/src/@types/compiler.ts
index 6435aea80..d35dcfd09 100644
--- a/packages/astro/src/@types/compiler.ts
+++ b/packages/astro/src/@types/compiler.ts
@@ -7,5 +7,4 @@ export interface CompileOptions {
astroConfig: AstroConfig;
hmrPort?: number;
mode: RuntimeMode;
- tailwindConfig?: string;
}
diff --git a/packages/astro/src/compiler/transform/styles.ts b/packages/astro/src/compiler/transform/styles.ts
index e1199e9a6..d5a10b323 100644
--- a/packages/astro/src/compiler/transform/styles.ts
+++ b/packages/astro/src/compiler/transform/styles.ts
@@ -124,7 +124,7 @@ async function transformStyle(code: string, { logging, type, filename, scopedCla
try {
const require = createRequire(import.meta.url);
const tw = require.resolve('tailwindcss', { paths: [import.meta.url, process.cwd()] });
- postcssPlugins.push(require(tw) as any);
+ postcssPlugins.push(require(tw)(tailwindConfig) as any);
} catch (err) {
error(logging, 'transform', err);
throw new Error(`tailwindcss not installed. Try running \`npm install tailwindcss\` and trying again.`);
@@ -214,7 +214,7 @@ export default function transformStyles({ compileOptions, filename, fileID }: Tr
type: (langAttr && langAttr.value[0] && langAttr.value[0].data) || undefined,
filename,
scopedClass,
- tailwindConfig: compileOptions.tailwindConfig,
+ tailwindConfig: compileOptions.astroConfig.devOptions.tailwindConfig,
})
);
return;
diff --git a/packages/astro/src/runtime.ts b/packages/astro/src/runtime.ts
index e7f9efd1c..124c2ffdc 100644
--- a/packages/astro/src/runtime.ts
+++ b/packages/astro/src/runtime.ts
@@ -399,7 +399,7 @@ async function createSnowpack(astroConfig: AstroConfig, options: CreateSnowpackO
config: {
plugins: {
[resolveDependency('autoprefixer')]: {},
- ...(astroConfig.devOptions.tailwindConfig ? { [resolveDependency('tailwindcss')]: {} } : {}),
+ ...(astroConfig.devOptions.tailwindConfig ? { [resolveDependency('tailwindcss')]: astroConfig.devOptions.tailwindConfig } : {}),
},
},
},