Error when dash is used as custom separator (#4704)

This commit is contained in:
Adam Wathan 2021-06-18 16:01:38 -04:00 committed by GitHub
parent ff14cb5ada
commit 1d72dc2699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 0 deletions

View File

@ -35,6 +35,12 @@ export default function processTailwindFeatures(setupContext) {
},
})(root, result)
if (context.tailwindConfig.separator === '-') {
throw new Error(
"The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead."
)
}
expandTailwindAtRules(context)(root, result)
expandApplyAtRules(context)(root, result)
evaluateTailwindFunctions(context)(root, result)

View File

@ -29,3 +29,21 @@ test('custom separator', () => {
expect(result.css).toMatchFormattedCss(expected)
})
})
test('dash is not supported', () => {
let config = {
darkMode: 'class',
mode: 'jit',
purge: [{ raw: 'lg-hover-font-bold' }],
separator: '-',
corePlugins: {},
theme: {},
plugins: [],
}
let css = `@tailwind utilities`
return expect(run(css, config)).rejects.toThrowError(
"The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead."
)
})