Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tailwind plugins not working? #3914

Open
waldemar-p opened this issue Oct 13, 2022 · 5 comments
Open

Tailwind plugins not working? #3914

waldemar-p opened this issue Oct 13, 2022 · 5 comments
Labels

Comments

@waldemar-p
Copy link
Contributor

To Reproduce

Step by step instructions to reproduce the behavior:

  1. Install Tailwind the usual way (don't forget postcss.config.js and include tailwindcss there) and init to have tailwind.config.js
    2.1 npm i -D tailwindcss && npx tailwindcss init --postcss
  2. Go into the tailwind.config.js
  3. add a plugin
    4.1 via npm
  const plugin = require("tailwindcss/plugin");
  
  module.exports = {
    content: ["./views/**/*.{html,js}", "./modules/**/*.{html,js}"],
    presets: [],
    plugins: [
      require('@tailwindcss/typography'),
    ]
    ...
  };

4.2 or manually

  const plugin = require("tailwindcss/plugin");
  
  module.exports = {
    content: ["./views/**/*.{html,js}", "./modules/**/*.{html,js}"],
    presets: [],
    plugins: [
      plugin(function ({ addComponents }) {
        addComponents({ ".i-am-a-class": { color: "black" } });
      }),
    ],
    ...
  };  
  1. To be safe, add class(es) to safelist via
  const plugin = require("tailwindcss/plugin");
  
  module.exports = {
    content: ["./views/**/*.{html,js}", "./modules/**/*.{html,js}"],
    presets: [],
    safelist: [
      'i-am-a-class'
    ],
    plugins: [
      plugin(function ({ addComponents }) {
        addComponents({ ".i-am-a-class": { color: "black" } });
      }),
    ],
    ...
  };
  1. Run APOS_DEV=1 npm run dev
  2. Open http://localhost:3000/apos-frontend/default/apos-bundle.css
  3. Search for a class, for example i-am-a-class

Expected behavior

The class i-am-a-class to be present in the bundled CSS file.

Describe the bug

The class i-am-a-class is missing from the bundled CSS file.

Details

Version of Node.js:
14.18.0

Server Operating System:
I am running this on my dev laptop with MacOS Monitery 12.6.

@waldemar-p waldemar-p added the bug label Oct 13, 2022
@BoDonkey
Copy link
Contributor

Howdy,
I wasn't able to reproduce the bug. Are you including @tailwind components; in your module /ui/src/index.scss file?
Cheers

@waldemar-p
Copy link
Contributor Author

Hello,

Yes, I am including them.

image

So after following my steps the desired class is added to the bundle? Now I am confused.

@BoDonkey
Copy link
Contributor

Sorry, not sure. But I'm glad it is working! I'm going to close this issue. Reach out if you have any other problem.

@waldemar-p
Copy link
Contributor Author

Sorry, I think we misunderstood each other. I thought it was working for you and was confused because it is not for me. 😅

@boutell boutell reopened this Oct 18, 2022
@boutell
Copy link
Member

boutell commented Oct 18, 2022

@waldemar-p I think this will move faster if you can share a simple project based on our a3-boilerplate that demonstrates the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants