Make WordPress Core

Changeset 55193


Ignore:
Timestamp:
02/02/2023 06:57:39 PM (22 months ago)
Author:
flixos90
Message:

Editor: Remove unnecessary CSS comments from compiled styles.

Props aristath, adamsilverstein, SergeyBiryukov, gziolo.
Fixes #56388.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/webpack/shared.js

    r54307 r55193  
    5858
    5959const stylesTransform = ( mode ) => ( content ) => {
    60     if ( mode === 'production' ) {
    61         return postcss( [
    62             require( 'cssnano' )( {
    63                 preset: 'default',
    64             } ),
    65         ] )
    66             .process( content, { from: 'src/app.css', to: 'dest/app.css' } )
    67             .then( ( result ) => result.css );
    68     }
    69     return content;
     60    return postcss( [
     61        require( 'cssnano' )( {
     62            preset: mode === 'production' ? 'default' : [
     63                'default',
     64                {
     65                    discardComments: {
     66                        removeAll: ! content.includes( 'Copyright' ) && ! content.includes( 'License' ),
     67                    },
     68                    normalizeWhitespace: false,
     69                },
     70            ],
     71        } ),
     72    ] )
     73        .process( content, { from: 'src/app.css', to: 'dest/app.css' } )
     74        .then( ( result ) => result.css );
    7075};
    7176
Note: See TracChangeset for help on using the changeset viewer.