0
module.exports = function(grunt){
    'use strict';
    require('load-grunt-tasks')(grunt);

    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        //Lint JavaScript (validate JS)
        jshint: {
            all: {
                options: {
                    force: true
                },
                src: ['Gruntfile.js', 'source/js/*.js', 'source/views/js/*.js']
            }
        },
        // Lint CSS (validate CSS)
        csslint: {`enter code here`
            lax: {
                options: {
                    force: true
                },
                src: ['source/css/*.css', 'source/views/css/*.css']
            }
        },
        //Clean and New folder for optimized code
        clean: {
            dev: {
                src: ['dest/'],
            },
        },
        mkdir: {
            dev: {
                options: {
                    create: ['dest/']
                },
            },
        },
        //Copy thee files in 'dest' folder
        copy: {
            main: {
                files: []
                    {expand: true, cwd: 'source/', src: ['**'], dest: 'dest/'}
                ],
            },
        },
        //JS Minification
        uglify: {
            my_target: {
                files: [{
                    expand: true,
                    cwd: 'dest/js',
                    src: ['*.js'],
                    dest: 'dest/js'
                },{
                    expand: true,
                    cwd: 'dest/views/js',
                    src: ['*.js'],
                    dest: 'dest/views/js'
                }]
            }
        },
        //CSS Minification
        cssmin: {
            target: {
                files: [{
                    expand: true,
                    cwd: 'dist/css',
                    src: ['*.css'],
                    dest: 'dist/css',
                    ext: '.css'
                },{
                    expand: true,
                    cwd: 'dist/views/css',
                    src: ['*.css'],
                    dest: 'dist/views/css',
                    ext: '.css'
                }]
            }
        },
        // resize images from pizza
        responsive_images: {
            dev: {
                options: {
                    engine: 'im',
                    sizes: [{
                        width: 77,
                        quality: 60
                    },{
                        width: 116,
                        quality: 60
                    },{
                        width: 232,
                        quality: 60
                    },{
                        width: 720,
                        quality: 60
                    }]
                },
                files: [{
                    expand: true,
                    src: ['**.{gif,jpg,png}'],
                    cwd: 'dest/views/images/',
                    dest: 'dest/views/images/'
                }]
            }
        }
    });
    grunt.registerTask('default', [
        'jshint',
        'csslint',
        'clean',
        'mkdir',
        'copy',
        'uglify',
        'cssmin',
        'responsive_images'
    ]);
};

Running grunt in Command Prompt gives ERROR:

Loading "gruntfile.js" tasks...ERROR >> SyntaxError: Unexpected token Warning: Task "default" not found. Use --force to continue.

I don't know where i have gone wrong..Any Help is Appreciated!

1 Answer 1

2

You have typo in your gruntfile.

Change

// ... config before
copy: {
    main: {
        files: []
            {expand: true, cwd: 'source/', src: ['**'], dest: 'dest/'}
        ],
    },
},
// ... config after

To:

// ... config before
copy: {
    main: {
        files: [ //removed array close
            {expand: true, cwd: 'source/', src: ['**'], dest: 'dest/'}
        ]
    }
},
// ... config after
Sign up to request clarification or add additional context in comments.

2 Comments

the commas should be unnecessary too!
@Legends you are right, I was just showing the real problem which the author is dealing with. Commas didn't break it, but I included it in the answer. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.