@@ -11,6 +11,7 @@ import fixRelativePathsPlugin from './postcss-fix-relative-paths'
1111interface CacheEntry {
1212 mtimes : Map < string , number >
1313 compiler : null | Awaited < ReturnType < typeof compile > >
14+ scanner : null | Scanner
1415 css : string
1516 optimizedCss : string
1617 fullRebuildPaths : string [ ]
@@ -23,7 +24,8 @@ function getContextFromCache(inputFile: string, opts: PluginOptions): CacheEntry
2324 if ( cache . has ( key ) ) return cache . get ( key ) !
2425 let entry = {
2526 mtimes : new Map < string , number > ( ) ,
26- compiler : null as null | Awaited < ReturnType < typeof compile > > ,
27+ compiler : null ,
28+ scanner : null ,
2729 css : '' ,
2830 optimizedCss : '' ,
2931 fullRebuildPaths : [ ] as string [ ] ,
@@ -123,18 +125,20 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
123125
124126 let css = ''
125127
126- // Look for candidates used to generate the CSS
127- let scanner = new Scanner ( {
128- detectSources : { base } ,
129- sources : context . compiler . globs ,
130- } )
128+ if ( context . scanner === null ) {
129+ // Look for candidates used to generate the CSS
130+ context . scanner = new Scanner ( {
131+ detectSources : { base } ,
132+ sources : context . compiler . globs ,
133+ } )
134+ }
131135
132136 env . DEBUG && console . time ( '[@tailwindcss/postcss] Scan for candidates' )
133- let candidates = scanner . scan ( )
137+ let candidates = context . scanner . scan ( )
134138 env . DEBUG && console . timeEnd ( '[@tailwindcss/postcss] Scan for candidates' )
135139
136140 // Add all found files as direct dependencies
137- for ( let file of scanner . files ) {
141+ for ( let file of context . scanner . files ) {
138142 result . messages . push ( {
139143 type : 'dependency' ,
140144 plugin : '@tailwindcss/postcss' ,
@@ -146,7 +150,7 @@ function tailwindcss(opts: PluginOptions = {}): AcceptedPlugin {
146150 // Register dependencies so changes in `base` cause a rebuild while
147151 // giving tools like Vite or Parcel a glob that can be used to limit
148152 // the files that cause a rebuild to only those that match it.
149- for ( let { base, pattern } of scanner . globs ) {
153+ for ( let { base, pattern } of context . scanner . globs ) {
150154 result . messages . push ( {
151155 type : 'dir-dependency' ,
152156 plugin : '@tailwindcss/postcss' ,
0 commit comments