Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip creating a compiler for CSS files that should not be processed #15340

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fix dependency related warnings when using `@tailwindcss/postcss` on Windows ([#15321](https://github.com/tailwindlabs/tailwindcss/pull/15321))
- Skip creating a compiler for CSS files that should not be processed ([#15340](https://github.com/tailwindlabs/tailwindcss/pull/15340))

## [4.0.0-beta.6] - 2024-12-06

Expand Down Expand Up @@ -749,3 +750,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Move the CLI into a separate `@tailwindcss/cli` package ([#13095](https://github.com/tailwindlabs/tailwindcss/pull/13095))

## [4.0.0-alpha.1] - 2024-03-06

23 changes: 23 additions & 0 deletions packages/@tailwindcss-postcss/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,29 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
postcssPlugin: 'tailwindcss',
async Once(root, { result }) {
env.DEBUG && console.time('[@tailwindcss/postcss] Total time in @tailwindcss/postcss')

// Bail out early if this is guaranteed to be a non-Tailwind CSS file.
{
let canBail = true
root.walkAtRules((node) => {
if (
node.name === 'import' ||
node.name === 'theme' ||
node.name === 'config' ||
node.name === 'plugin' ||
node.name === 'apply'
) {
canBail = false
return false
}
})
if (canBail) {
env.DEBUG &&
console.timeEnd('[@tailwindcss/postcss] Total time in @tailwindcss/postcss')
return
}
}

let inputFile = result.opts.from ?? ''
let context = getContextFromCache(inputFile, opts)
let inputBasePath = path.dirname(path.resolve(inputFile))
Expand Down