mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Add support for PostCSS Document nodes (#7291)
* Run Tailwind CSS once for each root in a postcss document * Update changelog
This commit is contained in:
parent
cd8f109981
commit
4fed060b7c
@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
|
||||
- Add `rgb` and `hsl` color helpers for CSS variables ([#7665](https://github.com/tailwindlabs/tailwindcss/pull/7665))
|
||||
- Support PostCSS `Document` nodes ([#7291](https://github.com/tailwindlabs/tailwindcss/pull/7291))
|
||||
|
||||
## [3.0.23] - 2022-02-16
|
||||
|
||||
|
||||
16
src/index.js
16
src/index.js
@ -13,7 +13,21 @@ module.exports = function tailwindcss(configOrPath) {
|
||||
return root
|
||||
},
|
||||
function (root, result) {
|
||||
processTailwindFeatures(setupTrackingContext(configOrPath))(root, result)
|
||||
let context = setupTrackingContext(configOrPath)
|
||||
|
||||
if (root.type === 'document') {
|
||||
let roots = root.nodes.filter((node) => node.type === 'root')
|
||||
|
||||
for (const root of roots) {
|
||||
if (root.type === 'root') {
|
||||
processTailwindFeatures(context)(root, result)
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
processTailwindFeatures(context)(root, result)
|
||||
},
|
||||
env.DEBUG &&
|
||||
function (root) {
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
import postcss from 'postcss'
|
||||
|
||||
import { run, css, html, defaults } from './util/run'
|
||||
|
||||
@ -568,3 +569,37 @@ test('The visited variant removes opacity support', () => {
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
||||
it('appends variants to the correct place when using postcss documents', () => {
|
||||
let config = {
|
||||
content: [{ raw: html`<div class="underline sm:underline"></div>` }],
|
||||
plugins: [],
|
||||
corePlugins: { preflight: false },
|
||||
}
|
||||
|
||||
const doc = postcss.document()
|
||||
doc.append(postcss.parse(`a {}`))
|
||||
doc.append(postcss.parse(`@tailwind base`))
|
||||
doc.append(postcss.parse(`@tailwind utilities`))
|
||||
doc.append(postcss.parse(`b {}`))
|
||||
|
||||
const result = doc.toResult()
|
||||
|
||||
return run(result, config).then((result) => {
|
||||
return expect(result.css).toMatchFormattedCss(css`
|
||||
a {
|
||||
}
|
||||
${defaults}
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
@media (min-width: 640px) {
|
||||
.sm\:underline {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
}
|
||||
b {
|
||||
}
|
||||
`)
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user