Skip to content

Commit

Permalink
bail early if we know it can't be a Tailwind CSS file
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinMalfait committed Dec 4, 2024
1 parent 0cbb6bb commit 776e646
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion packages/@tailwindcss-postcss/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,28 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
env.DEBUG && I.reset()

let inputFile = result.opts.from ?? ''

env.DEBUG && I.start(`[@tailwindcss/postcss] ${relative(base, inputFile)}`)

env.DEBUG && I.start('Quick bail check')
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 && I.report()
return
}
env.DEBUG && I.end('Quick bail check')

let context = getContextFromCache(inputFile, opts)
let inputBasePath = path.dirname(path.resolve(inputFile))

Expand Down

0 comments on commit 776e646

Please sign in to comment.