@@ -176,6 +176,29 @@ interface ProjectService {
176
176
onCodeAction ( params : CodeActionParams ) : Promise < CodeAction [ ] >
177
177
}
178
178
179
+ function getMode ( config : any ) : unknown {
180
+ if ( typeof config . mode !== 'undefined' ) {
181
+ return config . mode
182
+ }
183
+ if ( Array . isArray ( config . presets ) ) {
184
+ for ( let i = config . presets . length - 1 ; i >= 0 ; i -- ) {
185
+ let mode = getMode ( config . presets [ i ] )
186
+ if ( typeof mode !== 'undefined' ) {
187
+ return mode
188
+ }
189
+ }
190
+ }
191
+ }
192
+
193
+ function deleteMode ( config : any ) : void {
194
+ delete config . mode
195
+ if ( Array . isArray ( config . presets ) ) {
196
+ for ( let preset of config . presets ) {
197
+ deleteMode ( preset )
198
+ }
199
+ }
200
+ }
201
+
179
202
async function createProjectService (
180
203
folder : string ,
181
204
connection : Connection ,
@@ -755,7 +778,6 @@ async function createProjectService(
755
778
const sepLocation = semver . gte ( tailwindcss . version , '0.99.0' )
756
779
? [ 'separator' ]
757
780
: [ 'options' , 'separator' ]
758
- let presetModes : any [ ] = [ ]
759
781
let presetVariants : any [ ] = [ ]
760
782
let originalConfig : any
761
783
@@ -771,20 +793,8 @@ async function createProjectService(
771
793
dset ( exports , sepLocation , `__TWSEP__${ separator } __TWSEP__` )
772
794
exports [ isV3 ? 'content' : 'purge' ] = [ ]
773
795
774
- let mode : any
775
- if ( Array . isArray ( exports . presets ) ) {
776
- for ( let preset of exports . presets ) {
777
- if ( typeof preset . mode !== 'undefined' ) {
778
- mode = preset . mode
779
- }
780
- presetModes . push ( preset . mode )
781
- delete preset . mode
782
- }
783
- }
784
- if ( typeof exports . mode !== 'undefined' ) {
785
- mode = exports . mode
786
- }
787
- delete exports . mode
796
+ let mode = getMode ( exports )
797
+ deleteMode ( exports )
788
798
789
799
let isJit = isV3 || ( state . modules . jit && mode === 'jit' )
790
800
0 commit comments