Skip to content

Commit 5f49e53

Browse files
authored
Ignore content files that don't exist (#6901)
* 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
1 parent 78fb761 commit 5f49e53

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Fixed
1111

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

1415
## [3.0.10] - 2022-01-04
1516

src/lib/setupContextUtils.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,14 @@ function trackModified(files, fileModifiedMap) {
435435
let parsed = url.parse(file)
436436
let pathname = parsed.hash ? parsed.href.replace(parsed.hash, '') : parsed.href
437437
pathname = parsed.search ? pathname.replace(parsed.search, '') : pathname
438-
let newModified = fs.statSync(decodeURIComponent(pathname)).mtimeMs
438+
let newModified = fs.statSync(decodeURIComponent(pathname), { throwIfNoEntry: false })?.mtimeMs
439+
if (!newModified) {
440+
// It could happen that a file is passed in that doesn't exist. E.g.:
441+
// postcss-cli will provide you a fake path when reading from stdin. This
442+
// path then looks like /path-to-your-project/stdin In that case we just
443+
// want to ignore it and don't track changes at all.
444+
continue
445+
}
439446

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

0 commit comments

Comments
 (0)