Build Tools: grunt build should only copy Core files.

Historically, `grunt build` has copied all files from the `src` directory to the `build` directory. This is usually fine, but can be super slow when there are lots of custom plugins or themes in the `src` directory.

To rectify this, we now only copy Core plugins and themes to `build`.

Props adamsilverstein, pento, johnbillion.
Fixes #44256.



git-svn-id: https://develop.svn.wordpress.org/trunk@43329 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Gary Pendergast 2018-06-01 01:28:53 +00:00
parent ecb3302b45
commit a26c24226c

View File

@ -11,7 +11,25 @@ module.exports = function(grunt) {
BUILD_DIR = 'build/',
BANNER_TEXT = '/*! This file is auto-generated */',
autoprefixer = require( 'autoprefixer' ),
phpUnitWatchGroup = grunt.option( 'group' );
phpUnitWatchGroup = grunt.option( 'group' ),
buildFiles = [
'*.php',
'*.txt',
'*.html',
'wp-includes/**', // Include everything in wp-includes.
'wp-admin/**', // Include everything in wp-admin.
'wp-content/index.php',
'wp-content/themes/index.php',
'wp-content/themes/twenty*/**',
'wp-content/plugins/index.php',
'wp-content/plugins/hello.php',
'wp-content/plugins/akismet/**'
],
cleanFiles = [];
buildFiles.forEach( function( buildFile ) {
cleanFiles.push( BUILD_DIR + buildFile );
} );
if ( 'watch:phpunit' === grunt.cli.tasks[ 0 ] && ! phpUnitWatchGroup ) {
grunt.log.writeln();
@ -82,7 +100,9 @@ module.exports = function(grunt) {
}
},
clean: {
all: [BUILD_DIR],
plugins: [BUILD_DIR + 'wp-content/plugins'],
themes: [BUILD_DIR + 'wp-content/themes'],
all: cleanFiles,
js: [BUILD_DIR + 'wp-admin/js/', BUILD_DIR + 'wp-includes/js/'],
dynamic: {
dot: true,
@ -111,14 +131,13 @@ module.exports = function(grunt) {
dot: true,
expand: true,
cwd: SOURCE_DIR,
src: [
'**',
src: buildFiles.concat( [
'!js/**', // JavaScript is extracted into separate copy tasks.
'!**/.{svn,git}/**', // Ignore version control directories.
'!.{svn,git}', // Exclude version control folders.
'!wp-includes/version.php', // Exclude version.php
'!index.php', '!wp-admin/index.php',
'!_index.php', '!wp-admin/_index.php'
],
] ),
dest: BUILD_DIR
},
{