-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
The style does not take effect when using the markdown extension plugin with tailwindcss #4433
Comments
tailwind works by scanning the source. In your contents property in tw config you probably will have md/vue files. But that class is not in those files, so the corresponding CSS is not generated. You'll need to safelist it - https://tailwindcss.com/docs/content-configuration#safelisting-classes Edit - You can also try adding mjs extension to contents. It should work. If it doesn't, probably directories starting with dot are ignored by glob. You can specify something like In tailwind v4, you can register its vite plugin but you'll need move its scan plugin after vitepress. Not tricky stuff, but not trivial either: export default defineConfig({
vite: {
plugins: [
tailwindcss() as any,
{
name: 'vp-tw-order-fix',
configResolved(c) {
movePlugin(
c.plugins as any,
'@tailwindcss/vite:scan',
'after',
'vitepress'
)
},
},
],
},
})
function movePlugin(
plugins: { name: string }[],
pluginAName: string,
order: 'before' | 'after',
pluginBName: string
) {
const pluginBIndex = plugins.findIndex((p) => p.name === pluginBName)
if (pluginBIndex === -1) return
const pluginAIndex = plugins.findIndex((p) => p.name === pluginAName)
if (pluginAIndex === -1) return
if (order === 'before' && pluginAIndex > pluginBIndex) {
const pluginA = plugins.splice(pluginAIndex, 1)[0]
plugins.splice(pluginBIndex, 0, pluginA)
}
if (order === 'after' && pluginAIndex < pluginBIndex) {
const pluginA = plugins.splice(pluginAIndex, 1)[0]
plugins.splice(pluginBIndex, 0, pluginA)
}
} |
@brc-dd Thank you very much for taking the time to investigate this matter multiple times. You have been a great help to me If I move the PostCSS and TW configurations to the docs directory of my GitHub repository and start the development server, the console will display the following warning I think the original position was correct, there's no need to move it I tried to register the point directory in the content attribute of the TW configuration file, and the style started to take effect As the issue has been resolved, I have decided to close it |
Describe the bug
I have written a markdown it plugin, and the code is as follows
It's just a simple syntax parse(This is not the main point, it is just a simple plugin written to illustrate the issue)
Enter the following content in the markdown file
I have followed the tailwindcss guideInstallation
Then start the development server
But its'. bg-red-300 'style did not take effect
But when I continued to input an HTML fragment carrying 'bg-red-300' in markdown, it took effect
When I deleted the HTML fragment carrying 'bg-red-300' and restarted the development server, it had no effect again
refer to:
https://github.com/ajiho/vitepress-tailwindcss-markdown-it
This problem has been bothering me for a long time, can you help me?
Reproduction
refer to
Expected behavior
After the parse plugin of markdown it renders, the tailwindcss style should take effect immediately
System Info
Additional context
No response
Validations
The text was updated successfully, but these errors were encountered: