Skip to content

Commit

Permalink
Error when dash is used as custom separator (#4704)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamwathan committed Jun 18, 2021
1 parent ff14cb5 commit 1d72dc2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/jit/processTailwindFeatures.js
Expand Up @@ -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)
Expand Down
18 changes: 18 additions & 0 deletions tests/jit/custom-separator.test.js
Expand Up @@ -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."
)
})

1 comment on commit 1d72dc2

@harvanchik
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing error message: clear and concise. Keep up the great work!

Please sign in to comment.