Search code examples
javascriptgruntjsuglifyjsgrunt-contrib-uglify

Is it possible to only minify unminified JS files with grunt uglify


I want to use this grunt uglify setup shown in the accepted answer here: How to minify multiple Javascript files in a folder with UglifyJS?

However I only want to run it on files that are unminified, can uglify check this or not?

If not, any way of making it do this? Either by checking the size of the file/number of lines or maybe just checking if the file name ends in '.min.js'


Solution

  • When you set the src for the uglify task to

    src: ['js/*.js', '!js/*.min.js'],
    

    All the .min.jsfiles are not processed by uglify.

    See also: http://gruntjs.com/configuring-tasks#globbing-patterns