how to config grunt.js to minify files separately

looping picture looping · Nov 13, 2012 · Viewed 48.1k times · Source

there are some js files in static/js/

    1. a.js
    2. b.js
    3. c.js   

how to config grunt.js to get below files:

    1. a.min.js
    2. b.min.js
    3. c.min.js

as far, I have to type specific file name:

  min: {
    dist: {
    src:  'js/**/*.js',
    dest: 'js/min/xxx.min.js'
   }
 }

Answer

Frank Parent picture Frank Parent · Mar 22, 2013

Had the same problem and found a solution that would automatically minify all my scripts separately:

uglify: {
      build: {
        files: [{
            expand: true,
            src: '**/*.js',
            dest: 'build/scripts',
            cwd: 'app/scripts'
        }]
      }
    }