Skip to content

Commit 42b3ae2

Browse files
author
mcha
committed
separator :
1 parent 76cc50c commit 42b3ae2

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

src/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import autoprefixer from 'autoprefixer';
66
function postcssTw(purgeFile) {
77
const processors = [
88
tailwindcss({
9-
config: { mode: 'jit', purge: [purgeFile], separator: '_' },
9+
config: { mode: 'jit', purge: [purgeFile], separator: ':' },
1010
}),
1111
autoprefixer,
1212
];
@@ -36,7 +36,12 @@ export default function litTailwindcss(options = defaultOptions) {
3636

3737
if (code.includes(options.placeholder)) {
3838
return postcssTw(id).then((result) =>
39-
result.css ? code.replace(options.placeholder, result.css) : null,
39+
result.css
40+
? code.replace(
41+
options.placeholder,
42+
result.css.replaceAll(':', '\\:'),
43+
)
44+
: null,
4045
);
4146
}
4247
return null;

test/fixtures/component.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,12 @@ export class SimpleComponent extends LitElement {
55
static styles = css`tw_placeholder`;
66

77
render() {
8-
return html`<h1 class="text-purple-400 hover_text-green-500">
8+
return html`<h1
9+
class="text-purple-400 hover:text-green-500 md:text-red-400 md:hover:text-indigo-900"
10+
>
911
Hello, world!
1012
</h1>`;
1113
}
1214
}
1315

14-
customElements.define('simple-component', SimpleComponent);
16+
customElements.define('simple-component', SimpleComponent);

test/snapshots/test.js.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,31 @@ Generated by [AVA](https://avajs.dev).
1313
1414
class SimpleComponent extends lit.LitElement {␊
1515
static styles = lit.css\`.static {␊
16-
position: static␊
16+
position\\: static␊
1717
}␊
1818
.text-purple-400 {␊
19-
--tw-text-opacity: 1;␊
20-
color: rgba(167, 139, 250, var(--tw-text-opacity))␊
19+
--tw-text-opacity\\: 1;␊
20+
color\\: rgba(167, 139, 250, var(--tw-text-opacity))␊
2121
}␊
22-
.hover_text-green-500:hover {␊
23-
--tw-text-opacity: 1;␊
24-
color: rgba(16, 185, 129, var(--tw-text-opacity))␊
22+
.hover\\\\:text-green-500\\:hover {␊
23+
--tw-text-opacity\\: 1;␊
24+
color\\: rgba(16, 185, 129, var(--tw-text-opacity))␊
25+
}␊
26+
@media (min-width\\: 768px) {␊
27+
.md\\\\:text-red-400 {␊
28+
--tw-text-opacity\\: 1;␊
29+
color\\: rgba(248, 113, 113, var(--tw-text-opacity))␊
30+
}␊
31+
.md\\\\:hover\\\\:text-indigo-900\\:hover {␊
32+
--tw-text-opacity\\: 1;␊
33+
color\\: rgba(49, 46, 129, var(--tw-text-opacity))␊
34+
}␊
2535
}\`;␊
2636
2737
render() {␊
28-
return lit.html\`<h1 class="text-purple-400 hover_text-green-500">␊
38+
return lit.html\`<h1␊
39+
class="text-purple-400 hover:text-green-500 md:text-red-400 md:hover:text-indigo-900"␊
40+
>␊
2941
Hello, world!␊
3042
</h1>\`;␊
3143
}␊

test/snapshots/test.js.snap

94 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)