Search code examples
javascriptgruntjsgrunt-contrib-uglify

Why is Grunt ignoring jQuery when Uglifying?


I can't figure out why jQuery is being ignored when running my Grunt task. Here is what it looks like:

module.exports = function (grunt) {
    // Configuration
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        // Concat
        concat: {
            js: {
                src: [
                    'js/vendor/jquery.js',
                    'js/app/graph.js',
                ],
                dest: 'app/build/js/app.js'
            }
        },
        // Uglify
        uglify: {
            options: {
                preserveComments: false
            },
            my_target: {
                files: {
                    'app/build/js/app.min.js': [
                            'app/build/js/app.js'
                        ]
                }
            }
        });
};

When I check app.js, jQuery is part of it, but not in app.min.js. So I suspect something is wrong with the Uglify part.


Solution

  • github.com/gruntjs/grunt-contrib-clean This is not strictly necessary, jQuery should be included if that's all you've got. Do a test on the included site to be sure it's not just hiding somewhere in the uglified code.