From 16312b141b9a8533850bd62eebfd1648d65a2448 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 9 Sep 2015 02:11:23 +0000 Subject: [PATCH] Speed up `browserify` builds, don't `uglify` the media builds on `watch`. Props iseulde. Fixes #31911. git-svn-id: https://develop.svn.wordpress.org/trunk@33960 602fd350-edb4-49c9-b593-d223f7449a82 --- Gruntfile.js | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9e7a48ce8f..25069f995d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -534,6 +534,7 @@ module.exports = function(grunt) { all: { files: [ SOURCE_DIR + '**', + '!' + SOURCE_DIR + 'wp-includes/js/media/**', // Ignore version control directories. '!' + SOURCE_DIR + '**/.{svn,git}/**' ], @@ -549,7 +550,10 @@ module.exports = function(grunt) { SOURCE_DIR + 'wp-includes/js/media/**/*.js', '!' + SOURCE_DIR + 'wp-includes/js/media/*.manifest.js' ], - tasks: ['browserify'] + tasks: ['browserify', 'copy:dynamic'], + options: { + spawn: false + } }, config: { files: 'Gruntfile.js' @@ -670,22 +674,26 @@ module.exports = function(grunt) { // Default task. grunt.registerTask('default', ['build']); - // Add a listener to the watch task. - // - // On `watch:all`, automatically updates the `copy:dynamic` and `clean:dynamic` - // configurations so that only the changed files are updated. - // On `watch:rtl`, automatically updates the `rtlcss:dynamic` configuration. + /* + * Automatically updates the `:dynamic` configurations + * so that only the changed files are updated. + */ grunt.event.on('watch', function( action, filepath, target ) { - if ( target !== 'all' && target !== 'rtl' ) { + var src; + + if ( [ 'all', 'rtl', 'browserify' ].indexOf( target ) === -1 ) { return; } - var relativePath = path.relative( SOURCE_DIR, filepath ), - cleanSrc = ( action === 'deleted' ) ? [relativePath] : [], - copySrc = ( action === 'deleted' ) ? [] : [relativePath]; + src = [ path.relative( SOURCE_DIR, filepath ) ]; + if ( action === 'deleted' ) { + grunt.config( [ 'clean', 'dynamic', 'src' ], src ); + } else { + grunt.config( [ 'copy', 'dynamic', 'src' ], src ); - grunt.config(['clean', 'dynamic', 'src'], cleanSrc); - grunt.config(['copy', 'dynamic', 'src'], copySrc); - grunt.config(['rtlcss', 'dynamic', 'src'], copySrc); + if ( target === 'rtl' ) { + grunt.config( [ 'rtlcss', 'dynamic', 'src' ], src ); + } + } }); };