From a26c24226c6b131a0ed22c722a836c100d3ba254 Mon Sep 17 00:00:00 2001 From: Gary Pendergast Date: Fri, 1 Jun 2018 01:28:53 +0000 Subject: [PATCH] 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 --- Gruntfile.js | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 32e56cc4cc..8afa3c7767 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -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 }, {