|
1 | 1 | const fs = require('fs')
|
2 | 2 | const path = require('path')
|
3 | 3 | const fastGlob = require('fast-glob')
|
| 4 | +const parseGlob = require('parse-glob') |
4 | 5 | const sharedState = require('./sharedState')
|
5 | 6 | const { generateRules } = require('./generateRules')
|
6 | 7 | const { bigSign, cloneNodes } = require('./utils')
|
@@ -141,21 +142,55 @@ function expandTailwindAtRules(context, registerDependency) {
|
141 | 142 |
|
142 | 143 | // ---
|
143 | 144 |
|
144 |
| - // Register our temp file as a dependency — we write to this file |
145 |
| - // to trigger rebuilds. |
146 |
| - if (context.touchFile) { |
147 |
| - registerDependency(context.touchFile) |
148 |
| - } |
| 145 | + if (sharedState.env.TAILWIND_DISABLE_TOUCH) { |
| 146 | + for (let maybeGlob of context.candidateFiles) { |
| 147 | + let { |
| 148 | + is: { glob: isGlob }, |
| 149 | + base, |
| 150 | + } = parseGlob(maybeGlob) |
| 151 | + |
| 152 | + if (isGlob) { |
| 153 | + // register base dir as `dependency` _and_ `context-dependency` for |
| 154 | + // increased compatibility |
| 155 | + registerDependency(path.resolve(base)) |
| 156 | + registerDependency(path.resolve(base), 'context-dependency') |
| 157 | + } else { |
| 158 | + registerDependency(path.resolve(maybeGlob)) |
| 159 | + } |
| 160 | + } |
149 | 161 |
|
150 |
| - // If we're not set up and watching files ourselves, we need to do |
151 |
| - // the work of grabbing all of the template files for candidate |
152 |
| - // detection. |
153 |
| - if (!context.scannedContent) { |
| 162 | + env.DEBUG && console.time('Finding changed files') |
154 | 163 | let files = fastGlob.sync(context.candidateFiles)
|
155 | 164 | for (let file of files) {
|
156 |
| - context.changedFiles.add(file) |
| 165 | + let prevModified = context.fileModifiedMap.has(file) |
| 166 | + ? context.fileModifiedMap.get(file) |
| 167 | + : -Infinity |
| 168 | + let modified = fs.statSync(file).mtimeMs |
| 169 | + |
| 170 | + if (!context.scannedContent || modified > prevModified) { |
| 171 | + context.changedFiles.add(file) |
| 172 | + context.fileModifiedMap.set(file, modified) |
| 173 | + } |
157 | 174 | }
|
158 | 175 | context.scannedContent = true
|
| 176 | + env.DEBUG && console.timeEnd('Finding changed files') |
| 177 | + } else { |
| 178 | + // Register our temp file as a dependency — we write to this file |
| 179 | + // to trigger rebuilds. |
| 180 | + if (context.touchFile) { |
| 181 | + registerDependency(context.touchFile) |
| 182 | + } |
| 183 | + |
| 184 | + // If we're not set up and watching files ourselves, we need to do |
| 185 | + // the work of grabbing all of the template files for candidate |
| 186 | + // detection. |
| 187 | + if (!context.scannedContent) { |
| 188 | + let files = fastGlob.sync(context.candidateFiles) |
| 189 | + for (let file of files) { |
| 190 | + context.changedFiles.add(file) |
| 191 | + } |
| 192 | + context.scannedContent = true |
| 193 | + } |
159 | 194 | }
|
160 | 195 |
|
161 | 196 | // ---
|
|
0 commit comments