[Help] How to properly handle custom css? #521
Replies: 9 comments
-
What is your custom CSS? Are you using those selectors in HTML? There are 2 things that will remove unused CSS:
|
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your guide. Suppose that I have some custom CSS like below which works nice in the browser, how should I process it to be email-compatible? It seems like the code is ignored and left there on the email out:
|
Beta Was this translation helpful? Give feedback.
-
Do you apply the CSS variables have very poor support in email, just stick to HEX colors or use an actual opacity value if you really want to use rgba(). If that CSS in your example is generated by Tailwind, you probably enabled Maizzle specifically disables utilities that use CSS variables in Tailwind, such as If you wrote that manually in a .css file, again, just use HEX or replace the variable with an actual opacity value. |
Beta Was this translation helpful? Give feedback.
-
I see what you mean, I thought that maizzle has a way to convert these variable codes to css as well, but yeah I think it does make sense now. The code is automatically generated but I can certain update it. For some reason, the final output from maizzle misses some styles such as margin. I wonder if there is something specific related to the purge configs that I miss. Below is my code to build:
In the tailwindcss config file, do I need to configure purge or is it automatically set? Right now I simply use something like this:
However, since I pass the html via out-file, it seems wrong? Also, another questions is that when I switched from mjs to js (nodejs), I cannot use await on Maizzle.render anymore. Is there any way to force the script to wait for the response instead? The error I get is "SyntaxError: await is only valid in async function" |
Beta Was this translation helpful? Give feedback.
-
If you provide the framework/src/generators/output/to-string.js Lines 30 to 34 in 657476a So the purge path in your Tailwind config won't be used (nothing in there will be used, Maizzle will just use the CSS you provided in the Also, this:
... looks like you're providing a Maizzle config instead of a Tailwind one? Or is it just named like that but it contains the Tailwind config object? Also this:
... should be enough to set
It should work without you having to provide it: framework/src/generators/tailwindcss.js Lines 38 to 41 in 657476a |
Beta Was this translation helpful? Give feedback.
-
Thank you very much for your reply.
|
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thank you very much. For number 3, when I copied the code from the docs:
I get undefined for bot html and config, or perhaps I need to put the code in then to utilize the Promise instead? |
Beta Was this translation helpful? Give feedback.
-
Yes, the example is incomplete - will fix it. Either wrap it in an async function, i.e.: async function render() {
const {html} = await Maizzle.render('html string', options)
console.log(html)
}
render() ... or a self-invoking one: (async () => {
const {html} = await Maizzle.render('html string', options)
console.log(html)
})() ... or use a Promise: Maizzle
.render('html string', options)
.then(({html, config}) => console.log(html, config))
.catch(error => console.log(error)) |
Beta Was this translation helpful? Give feedback.
-
I'm in a situation where I have the html code generated with tailwind classes and some custom css. When I run maizzle it seems to remove all the custom css. I wonder if there is a proper way to handle this?
Thank you very much for your help.
Edit 1: I think the issue is with removeUnusedCSS on
Beta Was this translation helpful? Give feedback.
All reactions