Search code examples
gruntjsuglifyjsgrunt-contrib-uglify

grunt uglify not distorting variable names


I'm using grunt uglify and it doesn't seem to be mangling variable names. My "God" object is called "Porsche" and it keeps that and all it's functions readable as you can see here:

enter image description here

And this is my Gruntfile config:

uglify: {
    options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n',
        mangle: {
            except: ['jQuery', 'jquery']
        }
    },
    build: {
        src: [ 
            'assets/js/**/*.js'
        ],
        dest: 'assets/js/prod/all.min.js'
    }
}

I want it to completely mangle everything, saving bytes on function names. Is there anything I'm doing wrong?


Solution

  • I have figured it out:

    uglify: {
        options: {                  
            mangle: {
                toplevel: true
           }
        }
    }