| | 354 | }, |
| | 355 | plugins: { |
| | 356 | expand: true, |
| | 357 | cwd: SOURCE_DIR + 'wp-content/plugins', |
| | 358 | dest: BUILD_DIR, |
| | 359 | ext: '.min.js', |
| | 360 | src: [ |
| | 361 | '**/*.js', |
| | 362 | '!**/*.min.js' |
| | 363 | ], |
| | 364 | // Limit Uglify's run to a single specified plugin directory: |
| | 365 | // |
| | 366 | // grunt uglify:plugins --dir=foldername |
| | 367 | // |
| | 368 | filter: function( dirpath ) { |
| | 369 | var index, dir = grunt.option( 'dir' ); |
| | 370 | |
| | 371 | // Don't filter when no target folder is specified |
| | 372 | if ( ! dir ) { |
| | 373 | grunt.fail.fatal('No plugin directory specified, use --dir=foldername'); |
| | 374 | } |
| | 375 | |
| | 376 | dirpath = dirpath.replace( /\\/g, '/' ); |
| | 377 | index = dirpath.lastIndexOf( '/' + dir ); |
| | 378 | |
| | 379 | // Match only the folder name passed from cli |
| | 380 | if ( -1 !== index ) { |
| | 381 | return true; |
| | 382 | } |
| | 383 | |
| | 384 | return false; |
| | 385 | } |