@@ -379,13 +379,22 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
379
379
} ,
380
380
addBase ( base ) {
381
381
for ( let [ identifier , rule ] of withIdentifiers ( base ) ) {
382
+ let prefixedIdentifier =
383
+ identifier === '*'
384
+ ? '*'
385
+ : options . respectPrefix
386
+ ? context . tailwindConfig . prefix + identifier
387
+ : identifier
388
+
382
389
let offset = offsets . base ++
383
390
384
- if ( ! context . candidateRuleMap . has ( identifier ) ) {
385
- context . candidateRuleMap . set ( identifier , [ ] )
391
+ if ( ! context . candidateRuleMap . has ( prefixedIdentifier ) ) {
392
+ context . candidateRuleMap . set ( prefixedIdentifier , [ ] )
386
393
}
387
394
388
- context . candidateRuleMap . get ( identifier ) . push ( [ { sort : offset , layer : 'base' } , rule ] )
395
+ context . candidateRuleMap
396
+ . get ( prefixedIdentifier )
397
+ . push ( [ { sort : offset , layer : 'base' } , rule ] )
389
398
}
390
399
} ,
391
400
addComponents ( components , options ) {
@@ -403,14 +412,20 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
403
412
)
404
413
405
414
for ( let [ identifier , rule ] of withIdentifiers ( components ) ) {
415
+ let prefixedIdentifier =
416
+ identifier === '*'
417
+ ? '*'
418
+ : options . respectPrefix
419
+ ? context . tailwindConfig . prefix + identifier
420
+ : identifier
406
421
let offset = offsets . components ++
407
422
408
- if ( ! context . candidateRuleMap . has ( identifier ) ) {
409
- context . candidateRuleMap . set ( identifier , [ ] )
423
+ if ( ! context . candidateRuleMap . has ( prefixedIdentifier ) ) {
424
+ context . candidateRuleMap . set ( prefixedIdentifier , [ ] )
410
425
}
411
426
412
427
context . candidateRuleMap
413
- . get ( identifier )
428
+ . get ( prefixedIdentifier )
414
429
. push ( [ { sort : offset , layer : 'components' , options } , rule ] )
415
430
}
416
431
} ,
@@ -429,30 +444,42 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
429
444
)
430
445
431
446
for ( let [ identifier , rule ] of withIdentifiers ( utilities ) ) {
447
+ let prefixedIdentifier =
448
+ identifier === '*'
449
+ ? '*'
450
+ : options . respectPrefix
451
+ ? context . tailwindConfig . prefix + identifier
452
+ : identifier
432
453
let offset = offsets . utilities ++
433
454
434
- if ( ! context . candidateRuleMap . has ( identifier ) ) {
435
- context . candidateRuleMap . set ( identifier , [ ] )
455
+ if ( ! context . candidateRuleMap . has ( prefixedIdentifier ) ) {
456
+ context . candidateRuleMap . set ( prefixedIdentifier , [ ] )
436
457
}
437
458
438
459
context . candidateRuleMap
439
- . get ( identifier )
460
+ . get ( prefixedIdentifier )
440
461
. push ( [ { sort : offset , layer : 'utilities' , options } , rule ] )
441
462
}
442
463
} ,
443
464
matchBase : function ( base ) {
444
465
let offset = offsets . base ++
445
466
446
467
for ( let identifier in base ) {
468
+ let prefixedIdentifier =
469
+ identifier === '*'
470
+ ? '*'
471
+ : options . respectPrefix
472
+ ? context . tailwindConfig . prefix + identifier
473
+ : identifier
447
474
let value = [ ] . concat ( base [ identifier ] )
448
475
449
476
let withOffsets = value . map ( ( rule ) => [ { sort : offset , layer : 'base' } , rule ] )
450
477
451
- if ( ! context . candidateRuleMap . has ( identifier ) ) {
452
- context . candidateRuleMap . set ( identifier , [ ] )
478
+ if ( ! context . candidateRuleMap . has ( prefixedIdentifier ) ) {
479
+ context . candidateRuleMap . set ( prefixedIdentifier , [ ] )
453
480
}
454
481
455
- context . candidateRuleMap . get ( identifier ) . push ( ...withOffsets )
482
+ context . candidateRuleMap . get ( prefixedIdentifier ) . push ( ...withOffsets )
456
483
}
457
484
} ,
458
485
matchUtilities : function ( utilities , options ) {
@@ -468,15 +495,22 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
468
495
let offset = offsets . utilities ++
469
496
470
497
for ( let identifier in utilities ) {
498
+ let prefixedIdentifier =
499
+ identifier === '*'
500
+ ? '*'
501
+ : options . respectPrefix
502
+ ? context . tailwindConfig . prefix + identifier
503
+ : identifier
504
+
471
505
let value = [ ] . concat ( utilities [ identifier ] )
472
506
473
507
let withOffsets = value . map ( ( rule ) => [ { sort : offset , layer : 'utilities' , options } , rule ] )
474
508
475
- if ( ! context . candidateRuleMap . has ( identifier ) ) {
476
- context . candidateRuleMap . set ( identifier , [ ] )
509
+ if ( ! context . candidateRuleMap . has ( prefixedIdentifier ) ) {
510
+ context . candidateRuleMap . set ( prefixedIdentifier , [ ] )
477
511
}
478
512
479
- context . candidateRuleMap . get ( identifier ) . push ( ...withOffsets )
513
+ context . candidateRuleMap . get ( prefixedIdentifier ) . push ( ...withOffsets )
480
514
}
481
515
} ,
482
516
// ---
@@ -488,21 +522,6 @@ function buildPluginApi(tailwindConfig, context, { variantList, variantMap, offs
488
522
insertInto ( variantList , variantName , options )
489
523
variantMap . set ( variantName , applyVariant )
490
524
} ,
491
- addComponents ( components ) {
492
- let offset = offsets . components ++
493
-
494
- for ( let identifier in components ) {
495
- let value = [ ] . concat ( components [ identifier ] )
496
-
497
- let withOffsets = value . map ( ( rule ) => [ { sort : offset , layer : 'components' } , rule ] )
498
-
499
- if ( ! context . candidateRuleMap . has ( identifier ) ) {
500
- context . candidateRuleMap . set ( identifier , [ ] )
501
- }
502
-
503
- context . candidateRuleMap . get ( identifier ) . push ( ...withOffsets )
504
- }
505
- } ,
506
525
} ,
507
526
}
508
527
}
@@ -710,21 +729,21 @@ function setupContext(configOrPath) {
710
729
if ( layerNode . params === 'base' ) {
711
730
for ( let node of layerNode . nodes ) {
712
731
layerPlugins . push ( function ( { addBase } ) {
713
- addBase ( node )
732
+ addBase ( node , { respectPrefix : false } )
714
733
} )
715
734
}
716
735
}
717
736
if ( layerNode . params === 'components' ) {
718
737
for ( let node of layerNode . nodes ) {
719
738
layerPlugins . push ( function ( { addComponents } ) {
720
- addComponents ( node )
739
+ addComponents ( node , { respectPrefix : false } )
721
740
} )
722
741
}
723
742
}
724
743
if ( layerNode . params === 'utilities' ) {
725
744
for ( let node of layerNode . nodes ) {
726
745
layerPlugins . push ( function ( { addUtilities } ) {
727
- addUtilities ( node )
746
+ addUtilities ( node , { respectPrefix : false } )
728
747
} )
729
748
}
730
749
}
0 commit comments