Skip to content

Commit 1d72dc2

Browse files
authored
Error when dash is used as custom separator (#4704)
1 parent ff14cb5 commit 1d72dc2

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/jit/processTailwindFeatures.js

+6
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ export default function processTailwindFeatures(setupContext) {
3535
},
3636
})(root, result)
3737

38+
if (context.tailwindConfig.separator === '-') {
39+
throw new Error(
40+
"The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead."
41+
)
42+
}
43+
3844
expandTailwindAtRules(context)(root, result)
3945
expandApplyAtRules(context)(root, result)
4046
evaluateTailwindFunctions(context)(root, result)

tests/jit/custom-separator.test.js

+18
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,21 @@ test('custom separator', () => {
2929
expect(result.css).toMatchFormattedCss(expected)
3030
})
3131
})
32+
33+
test('dash is not supported', () => {
34+
let config = {
35+
darkMode: 'class',
36+
mode: 'jit',
37+
purge: [{ raw: 'lg-hover-font-bold' }],
38+
separator: '-',
39+
corePlugins: {},
40+
theme: {},
41+
plugins: [],
42+
}
43+
44+
let css = `@tailwind utilities`
45+
46+
return expect(run(css, config)).rejects.toThrowError(
47+
"The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead."
48+
)
49+
})

0 commit comments

Comments
 (0)