Closed StefanoTesla closed 2 years ago
a lot of tries and fuond something very very strange.
I didn't had tailiwind typography...my bad? I didn't see any reason why I should had it....
anyway
Noting, afetr one month of work, was as I expected after generate.
I've create a component, put the same table. imported the component to the markdown and it sound like a magic: the style was ok
except the H1 H2 ecc.. style (centering cause size is ok)
I've remove the component, and it continue to work.... 💯
So...it's a bug? it's the last version of nuxt?
@StefanoTesla
It's appreciated if you follow the forms in the Issue Template, and provide the specific versions of packages and reproduction link. Otherwise, people can't be on the same page with you and can't tell something on the correct assumption.
@nuxt/content: v1.41.0 nuxt: v2.15.3
Fresh and new nuxt/nuxt content installation
https://github.com/StefanoTesla/cssproblem
In development pages are ok, html with classes are reproduced without problems
Development and static site look similar
Afert generate static site the pages coming from markup file containing html are borken
And now some ""magic""
If you take the repo, you test it, and you have the problem, check this:
Why???????
@StefanoTesla
Thank you for providing the reproduction. I checked your repo, and found the root cause and solution.
TLDR
You can fix the issue by setting purge.content
option in tailwind.config.js
for PurgeCSS to analyze markdown files in content
directory.
const path = require('path')
module.exports = {
purge: {
content: [
path.join(__dirname, './content/**/*.md')
]
}
}
Details
The reason why styles in the page are broken in generated pages (i.e. in production) is because the CSS classes used in markdown files are purged on build time by PurgeCSS, as you guessed.
You have to set the purge.content
option in tailwind.config.js
for PurgeCSS to analyze markdown files.
With @nuxtjs/tailwindcss
, only *.(vue|js|ts)
files in Nuxt default directories (e.g. pages
, components
) are specified by default (link).
This is why styles are shown as expected when you define the table as a Vue component.
By the way, it's natural that content
directory is not specified by default, because Nuxt Content module and Nuxt TailwindCSS module are independent from each other.
@StefanoTesla
Thank you for providing the reproduction. I checked your repo, and found the root cause and solution.
TLDR
You can fix the issue by setting
purge.content
option intailwind.config.js
for PurgeCSS to analyze markdown files incontent
directory.const path = require('path') module.exports = { purge: { content: [ path.join(__dirname, './content/**/*.md') ] } }
Details
The reason why styles in the page are broken in generated pages (i.e. in production) is because the CSS classes used in markdown files are purged on build time by PurgeCSS, as you guessed.
You have to set the
purge.content
option intailwind.config.js
for PurgeCSS to analyze markdown files.With
@nuxtjs/tailwindcss
, only*.(vue|js|ts)
files in Nuxt default directories (e.g.pages
,components
) are specified by default (link).This is why styles are shown as expected when you define the table as a Vue component.
By the way, it's natural that
content
directory is not specified by default, because Nuxt Content module and Nuxt TailwindCSS module are independent from each other.
I already did this in my project, but not in the demo repo
@StefanoTesla
Do you mean the issue is not fixed in your project?
Then, there might be some conditions specific to your project.
Without any more information or reproduction, I can't say anything that may helpful to you.
I have last version of nuxt, nuxt/content and node.js
What is expected??
By default I have h1,h2,h3... with taliwind text-center and I put some table in the markdown tables as this:
And after generate the site to static I will see what I see in development
What append?
After generate all pages of nuxt content don't have the style I wanted. Olso table are not as expected.
tailwind.config.js: