apostrophe
apostrophe copied to clipboard
Tailwind plugins not working?
To Reproduce
Step by step instructions to reproduce the behavior:
- Install Tailwind the usual way (don't forget
postcss.config.jsand include tailwindcss there) and init to havetailwind.config.js2.1npm i -D tailwindcss && npx tailwindcss init --postcss - Go into the
tailwind.config.js - 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" } });
}),
],
...
};
- 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" } });
}),
],
...
};
- Run
APOS_DEV=1 npm run dev - Open
http://localhost:3000/apos-frontend/default/apos-bundle.css - 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.
Howdy,
I wasn't able to reproduce the bug. Are you including @tailwind components; in your module /ui/src/index.scss file?
Cheers
Hello,
Yes, I am including them.
So after following my steps the desired class is added to the bundle? Now I am confused.
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.
Sorry, I think we misunderstood each other. I thought it was working for you and was confused because it is not for me. 😅
@waldemar-p I think this will move faster if you can share a simple project based on our a3-boilerplate that demonstrates the issue.