Skip to content

Commit

Permalink
Ignore content files that don't exist (#6901)
Browse files Browse the repository at this point in the history
* ignore content files that don't exist

PostCSS CLI will give you a fake file path that ends in /stdin if you
are reading from stdin.

* update changelog
  • Loading branch information
RobinMalfait committed Jan 5, 2022
1 parent 78fb761 commit 5f49e53
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Preserve case of css variables added by plugins ([#6888](https://github.com/tailwindlabs/tailwindcss/pull/6888))
- Ignore content files that don't exist ([#6901](https://github.com/tailwindlabs/tailwindcss/pull/6901))

## [3.0.10] - 2022-01-04

Expand Down
9 changes: 8 additions & 1 deletion src/lib/setupContextUtils.js
Expand Up @@ -435,7 +435,14 @@ function trackModified(files, fileModifiedMap) {
let parsed = url.parse(file)
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, '') : parsed.href
pathname = parsed.search ? pathname.replace(parsed.search, '') : pathname
let newModified = fs.statSync(decodeURIComponent(pathname)).mtimeMs
let newModified = fs.statSync(decodeURIComponent(pathname), { throwIfNoEntry: false })?.mtimeMs
if (!newModified) {
// It could happen that a file is passed in that doesn't exist. E.g.:
// postcss-cli will provide you a fake path when reading from stdin. This
// path then looks like /path-to-your-project/stdin In that case we just
// want to ignore it and don't track changes at all.
continue
}

if (!fileModifiedMap.has(file) || newModified > fileModifiedMap.get(file)) {
changed = true
Expand Down

0 comments on commit 5f49e53

Please sign in to comment.