From 62a5cd343c93c6911ba43c0f66acfda1fe19f2e6 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 18 Dec 2018 03:13:58 +0000 Subject: [PATCH] Build Tools: Don't include `.map` files in the build. These files are fairly large, and while they're useful in development, they're not needed in the final build. Props pento, mcsf. Merges [43931] and [43932] to trunk. See #45201. git-svn-id: https://develop.svn.wordpress.org/trunk@44282 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 7 ++++++- tools/webpack/packages.js | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index fdf4d86b03..05f25ac56d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -105,7 +105,11 @@ module.exports = function(grunt) { clean: { plugins: [BUILD_DIR + 'wp-content/plugins'], themes: [BUILD_DIR + 'wp-content/themes'], - all: cleanFiles, + all: [ + cleanFiles, + SOURCE_DIR + 'wp-includes/js/dist', + SOURCE_DIR + 'wp-includes/css/dist' + ], js: [BUILD_DIR + 'wp-admin/js/', BUILD_DIR + 'wp-includes/js/'], dynamic: { dot: true, @@ -138,6 +142,7 @@ module.exports = function(grunt) { '!js/**', // JavaScript is extracted into separate copy tasks. '!.{svn,git}', // Exclude version control folders. '!wp-includes/version.php', // Exclude version.php + '!**/*.map', // The build doesn't need .map files. '!index.php', '!wp-admin/index.php', '!_index.php', '!wp-admin/_index.php' ] ), diff --git a/tools/webpack/packages.js b/tools/webpack/packages.js index 76dfcce9bd..d2ab0d5e51 100644 --- a/tools/webpack/packages.js +++ b/tools/webpack/packages.js @@ -268,6 +268,14 @@ module.exports = function( env = { environment: 'production', watch: false, forc config.devtool = process.env.SOURCEMAP || 'source-map'; } + if ( env.forceBuildTarget ) { + delete config.devtool; + config.mode = 'production'; + config.optimization = { + minimize: false + }; + } + if ( config.mode === 'development' ) { config.plugins.push( new LiveReloadPlugin( { port: process.env.WORDPRESS_LIVE_RELOAD_PORT || 35729 } ) ); }