r/webdevelopment • • Apr 10 '22

tailwind css classes not taking effect

I'm having troubles getting started with tailwind css.
I used tailwind css before and didn't have many issues, not that frustrating anyway.
But now, first I had problems installing tailwind for this project via npm, apparently some permissions problems (which I don't believe) so then I just copied all tailwind files from a different project and took it from there. But the tailwind css classes still wouldn't take effect in the frontend. Updated tailwind and the browser and did everything the terminal told me to do until there were no errors anymore. Still no effect. Run build, cleared cached… the usual, doesn't work.

I still get this warning, which I guess is the problem:

warn - The `content` option in your Tailwind CSS configuration is missing or empty.
warn - Configure your content sources or your generated CSS will be missing styles.
warn - https://tailwindcss.com/docs/content-configuration

my order strucutre is as follow…

/templates/
> some_file.html
> some_file.php
> /tailwindcss/
> > /css/
> > > tailwind.css
> > /node_modules/
> > package-lock.json
> > package.json
> > postcss.config.js
> > /public/
> > tailwind.config.js

and in tailwind.config.js I have…

module.exports = {

theme: { extend: { colors: { 'ccborder': '#00FF91', // white … }, fontFamily: { 'cf-bold': ['Consolas-Bold', 'sans-serif'], 'cf-regular': ['Consolas', 'sans-serif'], }, ringColor: ['hover', 'active'], }, }, variants: {}, content: [ './src//*.{html,js}', './node_modules/tw-elements/dist/js//.js', './pages/**/.{html,js}', './components//*.{html,js}',
'./src//*.{html,php,js}', // trying many things as you can see, still warning says: missing or empty ], plugins: [ require('tw-elements/dist/plugin'), require('@tailwindcss/aspect-ratio'), require('@tailwindcss/custom-forms'), ] }

Thanks for help!

1 Upvotes

4 comments sorted by

1

u/[deleted] Apr 11 '22

You need to set the correct „content“ path, not just random values you’ve found on the internet. ../**/*.{php,html} is all that you need. All other paths you’ve provided are not useful in your folder structure.

For the future: it’s easier if you keep your package.json in the root of the project instead of a subfolder.

1

u/fred_from_earth Apr 11 '22

thanks, but I'm sure I also tried

../**/*.{php,html}

but since I only have php files I also tried

../**/*.php

However, why does it work with

content: ['../**/*.{php,js}', './node_modules/tw-elements/dist/js/**/*.js'],

which is default in the older project? both use the same file structure.

1

u/[deleted] Apr 12 '22

Does your php file contain any tailwind classes that can be picked up by the compiler?

1

u/meAndTheDuck Apr 11 '22

can you upload your project to github or gitlab? hard to debug without seeing everything