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
This commit is contained in:
parent
c0804fc8cd
commit
3ada25d7d9
5 changed files with 9 additions and 5 deletions
5
.changeset/breezy-parrots-bathe.md
Normal file
5
.changeset/breezy-parrots-bathe.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Pass configured Tailwind config file to the tailwindcss plugin
|
|
@ -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',
|
||||
+ },
|
||||
};
|
||||
```
|
||||
|
|
|
@ -7,5 +7,4 @@ export interface CompileOptions {
|
|||
astroConfig: AstroConfig;
|
||||
hmrPort?: number;
|
||||
mode: RuntimeMode;
|
||||
tailwindConfig?: string;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 } : {}),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue