javascriptcompressiongruntjs

How to configure Grunt to minify files separately


There are some .js files in folder static/js/:

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

How can I configure Grunt to get the below files:

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

As far, I have to type a specific file name:

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

Solution

  • I 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'
            }]
          }
        }