Fix using negated content globs (#5625)

* Fix negated content patterns

* Update changelog
This commit is contained in:
Brad Cornes 2021-09-29 11:15:31 +01:00 • committed by GitHub
parent c5c644f315
commit 0b23d2e1d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 39 additions and 3 deletions

View file

@ -33,6 +33,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
- Fix defining colors as functions when color opacity plugins are disabled ([#5470](https://github.com/tailwindlabs/tailwindcss/pull/5470))
- Fix using negated `content` globs ([#5625](https://github.com/tailwindlabs/tailwindcss/pull/5625))
## [2.2.16] - 2021-09-26

View file

@ -28,7 +28,7 @@ function getCandidateFiles(context, tailwindConfig) {
let candidateFiles = tailwindConfig.content.content
.filter((item) => typeof item === 'string')
.map((contentPath) => normalizePath(path.resolve(contentPath)))
.map((contentPath) => normalizePath(contentPath))
return candidateFilesCache.set(context, candidateFiles).get(context)
}
@ -159,7 +159,10 @@ export default function setupTrackingContext(configOrPath) {
// Add template paths as postcss dependencies.
for (let fileOrGlob of candidateFiles) {
registerDependency(parseDependency(fileOrGlob))
let dependency = parseDependency(fileOrGlob)
if (dependency) {
registerDependency(dependency)
}
}
for (let changedContent of resolvedChangedContent(

View file

@ -149,7 +149,7 @@ function getCandidateFiles(context, tailwindConfig) {
let candidateFiles = tailwindConfig.content.content
.filter((item) => typeof item === 'string')
.map((contentPath) => normalizePath(path.resolve(contentPath)))
.map((contentPath) => normalizePath(contentPath))
return candidateFilesCache.set(context, candidateFiles).get(context)
}

View file

@ -26,6 +26,10 @@ function parseGlob(pattern) {
}
export default function parseDependency(normalizedFileOrGlob) {
if (normalizedFileOrGlob.startsWith('!')) {
return null
}
let message
if (isGlob(normalizedFileOrGlob)) {

View file

@ -0,0 +1 @@
<div class="lowercase"></div>

View file

@ -0,0 +1 @@
<div class="uppercase"></div>

View file

@ -0,0 +1,26 @@
import * as path from 'path'
import { run, css } from './util/run'
it('should be possible to use negated content patterns', () => {
let config = {
content: [
path.resolve(__dirname, './negated-content-*.test.html'),
'!' + path.resolve(__dirname, './negated-content-ignore.test.html'),
],
corePlugins: { preflight: false },
}
let input = css`
@tailwind base;
@tailwind components;
@tailwind utilities;
`
return run(input, config).then((result) => {
expect(result.css).toMatchFormattedCss(css`
.uppercase {
text-transform: uppercase;
}
`)
})
})