Grunt: copying files very slow. How to improve performance?

943 Views Asked by At

I've inherited application code that uses Grunt (1.0.0) to build its AngularJS front-end.

What suprised me is that build action step 'copy' (implemented with grunt-contrib-copy plugin) takes very long time: more than 1 minute, while I would expect it to take less than a second.

Here are the execution time statistics for grunt build, including problematic copy tasks:

 loading tasks             1.4s  - 2%
 uglify:build             14.4s  ---------- 16%
 copy:common            1m 6.4s  ---------------------------------------- 76%
 copy:partner_xxxxx        4.9s  --- 6%

 Total 1m 27.9s

The number of copied files seems reasonable:

 Running "copy:common" (copy) task
 Created 12 directories, copied 179 files

Copying this same destination folder in Windows Explorer takes less than 1 second (drive is a fast SSD).

Here's how gulp task is defined:

copy: {
  common: {
    cwd: '.',
    src: [
      '**/*.html',
      '**/*.json',
      '**/*.cur',
      '**/partials/**/*.js',
      '**/directives/**/*.js',
      '**/app-services/**/*.js',
      '**/main-scripts/**/*.js',
      '**/bundles/**',
      '**/images/**',
      '**/utils/**',
      '!**/tests/**',
      '!**/partner-info/**',
      '!**/bower_components/**',
      '!**/node_modules/**',
      '!bower.json',
      '!package.json'
    ],
    dest: publishDest+ "//<%= grunt.option('partnerName') %>"
  },
  expand: true
}

My question is: is it normal for Grunt to be this slow? Are there any gotchas that may slow down this process? Do you see any ways to improve this time?

0

There are 0 best solutions below