diff --git a/src/lib/setupContextUtils.js b/src/lib/setupContextUtils.js index fe2191b7d5fa..00b05652af0d 100644 --- a/src/lib/setupContextUtils.js +++ b/src/lib/setupContextUtils.js @@ -231,8 +231,8 @@ export function parseVariant(variant) { return ({ format }) => format(str) } - let [, name, params] = /@(.*?)( .+|[({].*)/g.exec(str) - return ({ wrap }) => wrap(postcss.atRule({ name, params: params.trim() })) + let [, name, params] = /@(\S*)( .+|[({].*)?/g.exec(str) + return ({ wrap }) => wrap(postcss.atRule({ name, params: params?.trim() ?? '' })) }) .reverse() diff --git a/tests/variants.test.js b/tests/variants.test.js index f2a2de075acd..51980d8a09dd 100644 --- a/tests/variants.test.js +++ b/tests/variants.test.js @@ -54,6 +54,31 @@ test('order matters and produces different behaviour', () => { }) describe('custom advanced variants', () => { + test('at-rules without params', () => { + let config = { + content: [ + { + raw: html`
`, + }, + ], + plugins: [ + function ({ addVariant }) { + addVariant('ogre', '@layer') + }, + ], + } + + return run('@tailwind components; @tailwind utilities', config).then((result) => { + return expect(result.css).toMatchFormattedCss(css` + @layer { + .ogre\:text-center { + text-align: center; + } + } + `) + }) + }) + test('prose-headings usage on its own', () => { let config = { content: [