Search code examples
javascriptgruntjsuglifyjs

How works "except" attribute in Grunt Uglify?


I am trying to minify all my javascript files with Uglify, less jQuery and Modernizr files. I am using the attribute "except" inside the mangle options, writting jQuery and Modernizr, but it isn't work and everything is minifyed.

Here the Uglify options that I have in the Gruntfile.js:

options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n',
        mangle: {
          except: ['jQuery', 'Modernizr']
        }
  },

I have tried to put the name of the files jquery.min and modernizr.custom, but it doesn't work.

Resolved! Thank you Jashwant for your fast comment. Sorry for that, I didn't check fine the related questions.


Solution

  • Thank you to Jashwant I could resolve the problem. He link to me a related question where the solution was put ! before the files that I don't want to minify. Something like this:

    '!library/js/libs/jquery.min.js'
    

    Thank you!