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

fix(tailwind): add prefix to production class names #111

Merged
merged 3 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/jsx-email/src/components/tailwind/tailwind.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getUno = (config: ConfigBase, production: boolean) => {
if (production)
transformers.push(
transformerCompileClass({
classPrefix: '',
classPrefix: 'je-',
trigger: ':jsx:'
})
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ exports[`Custom theme config > should be able to use custom text alignment 1`] =
.text-justify{text-align:justify;}</style></div>"
`;

exports[`Production mode > should generate class names with a prefix 1`] = `
"<div data-id=\\"__jsx-email-twnd\\"><html data-id=\\"jsx-email/html\\" lang=\\"en\\" dir=\\"ltr\\"><div class=\\"je-5wyw0k\\"></div></html><style tailwind>/* layer: preflights */
/* layer: shortcuts */
.je-5wyw0k{background-color:rgb(254,226,226);font-size:0.875rem;line-height:1.25rem;}</style></div>"
`;

exports[`Responsive styles > should add css to <head/> 1`] = `
"<!DOCTYPE html PUBLIC \\"-//W3C//DTD XHTML 1.0 Transitional//EN\\" \\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\\"><html><head><style tailwind>/* layer: preflights */
/* layer: default */
Expand Down
14 changes: 14 additions & 0 deletions packages/jsx-email/test/tailwind/tailwind.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,17 @@ describe('<Tailwind> component', async () => {
);
});
});

describe('Production mode', async () => {
it('should generate class names with a prefix', async () => {
const actualOutput = await jsxToString(
<Tailwind production>
<Html>
<div className="text-sm bg-red-100" />
</Html>
</Tailwind>
);

expect(actualOutput).toMatchSnapshot();
});
});
Loading