Build/Test Tools: Replace the banner text from wp-emoji-loader.min.js in formatting.php during build process.

This ensures that `/*! This file is auto-generated */` comment is not included on front end as part of the inline Emoji detection script.

Follow-up to [41271], [46589].

Props superpoincare, SergeyBiryukov.
Fixes #49861.

git-svn-id: https://develop.svn.wordpress.org/trunk@48096 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2020-06-19 22:06:28 +00:00
parent 82cfc3f62d
commit 44def76306

View File

@ -1031,7 +1031,7 @@ module.exports = function(grunt) {
patterns: [
{
match: /\/\/ START: emoji arrays[\S\s]*\/\/ END: emoji arrays/g,
replacement: function () {
replacement: function() {
var regex, files,
partials, partialsSet,
entities, emojiArray;
@ -1057,7 +1057,7 @@ module.exports = function(grunt) {
entities = entities.replace( /-/g, '' );
// Sort the entities list by length, so the longest emoji will be found first.
emojiArray = entities.split( '\n' ).sort( function ( a, b ) {
emojiArray = entities.split( '\n' ).sort( function( a, b ) {
return b.length - a.length;
} );
@ -1097,6 +1097,26 @@ module.exports = function(grunt) {
dest: SOURCE_DIR + 'wp-includes/'
}
]
},
emojiBannerText: {
options: {
patterns: [
{
match: new RegExp( '\\s*' + BANNER_TEXT.replace( /[\/\*\!]/g, '\\$&' ) ),
replacement: ''
}
]
},
files: [
{
expand: true,
flatten: true,
src: [
BUILD_DIR + 'wp-includes/formatting.php'
],
dest: BUILD_DIR + 'wp-includes/'
}
]
}
},
_watch: {
@ -1419,6 +1439,7 @@ module.exports = function(grunt) {
'build:css',
'includes:emoji',
'includes:embed',
'replace:emojiBannerText'
] );
}
} );