@@ -5,40 +5,6 @@ import chalk from 'chalk'
55import { log } from '../cli/utils'
66import * as emoji from '../cli/emoji'
77
8- function convertLayersToControlComments ( css ) {
9- css . walkAtRules ( 'layer' , atRule => {
10- const layer = atRule . params
11- atRule . before ( postcss . comment ( { text : `tailwind start ${ layer } ` } ) )
12- atRule . before ( atRule . nodes )
13- atRule . before ( postcss . comment ( { text : `tailwind end ${ layer } ` } ) )
14- atRule . remove ( )
15- } )
16- }
17-
18- function convertControlCommentsToPurgeIgnoreComments ( config ) {
19- return function ( css ) {
20- const mode = _ . get ( config , 'purge.mode' , 'conservative' )
21-
22- if ( mode === 'conservative' ) {
23- css . prepend ( postcss . comment ( { text : 'purgecss start ignore' } ) )
24- css . append ( postcss . comment ( { text : 'purgecss end ignore' } ) )
25-
26- css . walkComments ( comment => {
27- switch ( comment . text . trim ( ) ) {
28- case 'tailwind start utilities' :
29- comment . text = 'purgecss end ignore'
30- break
31- case 'tailwind end utilities' :
32- comment . text = 'purgecss start ignore'
33- break
34- default :
35- break
36- }
37- } )
38- }
39- }
40- }
41-
428function removeTailwindComments ( css ) {
439 css . walkComments ( comment => {
4410 switch ( comment . text . trim ( ) ) {
@@ -62,7 +28,7 @@ export default function purgeUnusedUtilities(config) {
6228 )
6329
6430 if ( ! purgeEnabled ) {
65- return postcss ( [ convertLayersToControlComments , removeTailwindComments ] )
31+ return removeTailwindComments
6632 }
6733
6834 // Skip if `purge: []` since that's part of the default config
@@ -86,8 +52,27 @@ export default function purgeUnusedUtilities(config) {
8652 }
8753
8854 return postcss ( [
89- convertLayersToControlComments ,
90- convertControlCommentsToPurgeIgnoreComments ( config ) ,
55+ function ( css ) {
56+ const mode = _ . get ( config , 'purge.mode' , 'conservative' )
57+
58+ if ( mode === 'conservative' ) {
59+ css . prepend ( postcss . comment ( { text : 'purgecss start ignore' } ) )
60+ css . append ( postcss . comment ( { text : 'purgecss end ignore' } ) )
61+
62+ css . walkComments ( comment => {
63+ switch ( comment . text . trim ( ) ) {
64+ case 'tailwind start utilities' :
65+ comment . text = 'purgecss end ignore'
66+ break
67+ case 'tailwind end utilities' :
68+ comment . text = 'purgecss start ignore'
69+ break
70+ default :
71+ break
72+ }
73+ } )
74+ }
75+ } ,
9176 removeTailwindComments ,
9277 purgecss ( {
9378 content : Array . isArray ( config . purge ) ? config . purge : config . purge . content ,
0 commit comments