I am trying to include tailwindcss into my custom Gatsby Theme via twin.macro. I am using yarn workspaces and the project directory tree is setup as follows:
./site - The actual site which contains the content
./packages/gatsby-theme-custom/** - The Gatsby theme
So my site pulls in gatsby-theme-custom and fills it with its own contents.
The integration of tailwindcss per se has worked fine so far. Now I am trying to add a tailwind.config.js file to the root of gatsby-theme-custom but it seems the file does not get picked up during compilation. For example I was trying to extend the base theme with some custom colours:
module.exports = {
purge: [],
darkMode: false, // or 'media' or 'class'
theme: {
extend: {
colors: {
electric: "#db00ff",
ribbon: "#0047ff",
wonderfulgray: "#eeeeee",
},
},
},
variants: {
extend: {},
},
plugins: [],
};
Then in some file inside the theme:
import tw from "twin.macro";
...
return (
<div
css={[
tw`flex flex-col items-center justify-center h-screen`,
tw`bg-gradient-to-b from-electric to-wonderfulgray`,
]}
>
Test
</div>
)
When I now compile the site I am getting errors that the referenced colours cannot be found.
✕ from-electric was not found
When I put the config file into the root of the site everything is working fine. The issue now is that the site should basically not know anything about the styling. Everything related to the styling should be encapsulated into the theme. Is there a way to accomplish that tailwind is picking up the config file from the theme instead ? Or did I make some errors along the way ?
Any help is appreciated !