Skip to content

Commit 8ebea3c

Browse files
authored
fix(tailwind): add prefix to production class names (#111)
1 parent b13a382 commit 8ebea3c

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

packages/jsx-email/src/components/tailwind/tailwind.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const getUno = (config: ConfigBase, production: boolean) => {
3232
if (production)
3333
transformers.push(
3434
transformerCompileClass({
35-
classPrefix: '',
35+
classPrefix: 'je-',
3636
trigger: ':jsx:'
3737
})
3838
);

packages/jsx-email/test/tailwind/.snapshots/tailwind.test.tsx.snap

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ exports[`Custom theme config > should be able to use custom text alignment 1`] =
6666
.text-justify{text-align:justify;}</style></div>"
6767
`;
6868

69+
exports[`Production mode > should generate class names with a prefix 1`] = `
70+
"<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 */
71+
/* layer: shortcuts */
72+
.je-5wyw0k{background-color:rgb(254,226,226);font-size:0.875rem;line-height:1.25rem;}</style></div>"
73+
`;
74+
6975
exports[`Responsive styles > should add css to <head/> 1`] = `
7076
"<!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 */
7177
/* layer: default */

packages/jsx-email/test/tailwind/tailwind.test.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,17 @@ describe('<Tailwind> component', async () => {
259259
);
260260
});
261261
});
262+
263+
describe('Production mode', async () => {
264+
it('should generate class names with a prefix', async () => {
265+
const actualOutput = await jsxToString(
266+
<Tailwind production>
267+
<Html>
268+
<div className="text-sm bg-red-100" />
269+
</Html>
270+
</Tailwind>
271+
);
272+
273+
expect(actualOutput).toMatchSnapshot();
274+
});
275+
});

0 commit comments

Comments
 (0)